打字猴:1.70047306e+09
1700473060 public final static int OPENING_STATE=1;//敞门状态
1700473061
1700473062 public final static int CLOSING_STATE=2;//闭门状态
1700473063
1700473064 public final static int RUNNING_STATE=3;//运行状态
1700473065
1700473066 public final static int STOPPING_STATE=4;//停止状态
1700473067
1700473068 //设置电梯的状态
1700473069
1700473070 public void setState(int state);
1700473071
1700473072 //首先电梯门开启动作
1700473073
1700473074 public void open();
1700473075
1700473076 //电梯门可以开启,那当然也就有关闭了
1700473077
1700473078 public void close();
1700473079
1700473080 //电梯要能上能下,运行起来
1700473081
1700473082 public void run();
1700473083
1700473084 //电梯还要能停下来
1700473085
1700473086 public void stop();
1700473087
1700473088 }
1700473089
1700473090 这里增加了4个静态常量,并增加了一个方法setState,设置电梯的状态。我们再来看实现类是如何实现的,如代码清单26-5所示。
1700473091
1700473092 代码清单26-5 电梯实现类
1700473093
1700473094 public class Lift implements ILift{
1700473095
1700473096 private int state;
1700473097
1700473098 public void setState(int state){
1700473099
1700473100 this.state=state;
1700473101
1700473102 }
1700473103
1700473104 //电梯门关闭
1700473105
1700473106 public void close(){
1700473107
1700473108 //电梯在什么状态下才能关闭
1700473109
[ 上一页 ]  [ :1.70047306e+09 ]  [ 下一页 ]