打字猴:1.70046047e+09
1700460470
1700460471 }else{
1700460472
1700460473 System.out.println(“请使用指定的代理访问”);
1700460474
1700460475 }
1700460476
1700460477 }
1700460478
1700460479 //升级,升级有很多方法,花钱买是一种,做任务也是一种
1700460480
1700460481 public void upgrade(){
1700460482
1700460483 if(this.isProxy()){
1700460484
1700460485 System.out.println(this.name+“又升了一级!”);
1700460486
1700460487 }else{
1700460488
1700460489 System.out.println(“请使用指定的代理访问”);
1700460490
1700460491 }
1700460492
1700460493 }
1700460494
1700460495 //校验是否是代理访问
1700460496
1700460497 private boolean isProxy(){
1700460498
1700460499 if(this.proxy==null){
1700460500
1700460501 return false;
1700460502
1700460503 }else{
1700460504
1700460505 return true;
1700460506
1700460507 }
1700460508
1700460509 }
1700460510
1700460511 }
1700460512
1700460513 增加了一个私有方法,检查是否是自己指定的代理,是指定的代理则允许访问,否则不允许访问。我们再来看代理角色,如代码清单12-15所示。
1700460514
1700460515 代码清单12-15 强制代理的代理类
1700460516
1700460517 public class GamePlayerProxy implements IGamePlayer{
1700460518
1700460519 private IGamePlayer gamePlayer=null;
[ 上一页 ]  [ :1.70046047e+09 ]  [ 下一页 ]