打字猴:1.700473373e+09
1700473373 this.context=_context;
1700473374
1700473375 }
1700473376
1700473377 //首先电梯门开启动作
1700473378
1700473379 public abstract void open();
1700473380
1700473381 //电梯门有开启,那当然也就有关闭了
1700473382
1700473383 public abstract void close();
1700473384
1700473385 //电梯要能上能下,运行起来
1700473386
1700473387 public abstract void run();
1700473388
1700473389 //电梯还要能停下来
1700473390
1700473391 public abstract void stop();
1700473392
1700473393 }
1700473394
1700473395 抽象类比较简单,我们先看一个具体的实现——敞门状态的实现类,如代码清单26-8所示。
1700473396
1700473397 代码清单26-8 敞门状态
1700473398
1700473399 public class OpenningState extends LiftState{
1700473400
1700473401 //开启当然可以关闭了,我就想测试一下电梯门开关功能
1700473402
1700473403 @Override
1700473404
1700473405 public void close(){
1700473406
1700473407 //状态修改
1700473408
1700473409 super.context.setLiftState(Context.closeingState);
1700473410
1700473411 //动作委托为CloseState来执行
1700473412
1700473413 super.context.getLiftState().close();
1700473414
1700473415 }
1700473416
1700473417 //打开电梯门
1700473418
1700473419 @Override
1700473420
1700473421 public void open(){
1700473422
[ 上一页 ]  [ :1.700473373e+09 ]  [ 下一页 ]