1700459986
this.gamePlayer=_gamePlayer;
1700459987
1700459988
}
1700459989
1700459990
//代练杀怪
1700459991
1700459992
public void killBoss(){
1700459993
1700459994
this.gamePlayer.killBoss();
1700459995
1700459996
}
1700459997
1700459998
//代练登录
1700459999
1700460000
public void login(String user,String password){
1700460001
1700460002
this.gamePlayer.login(user,password);
1700460003
1700460004
}
1700460005
1700460006
//代练升级
1700460007
1700460008
public void upgrade(){
1700460009
1700460010
this.gamePlayer.upgrade();
1700460011
1700460012
}
1700460013
1700460014
}
1700460015
1700460016
很简单,首先通过构造函数说明要代谁打怪升级,然后通过手动开始代用户打怪、升级。场景类Client代码也稍作改动,如代码清单12-5所示。
1700460017
1700460018
代码清单12-5 改进后的场景类
1700460019
1700460020
public class Client{
1700460021
1700460022
public static void main(String[]args){
1700460023
1700460024
//定义一个痴迷的玩家
1700460025
1700460026
IGamePlayer player=new GamePlayer(“张三”);
1700460027
1700460028
//然后再定义一个代练者
1700460029
1700460030
IGamePlayer proxy=new GamePlayerProxy(player);
1700460031
1700460032
//开始打游戏,记下时间戳
1700460033
1700460034
System.out.println(“开始时间是:2009-8-25 10
:45”);
1700460035
[
上一页 ]
[ :1.700459986e+09 ]
[
下一页 ]