1700472960
}
1700472961
1700472962
//电梯开始运行起来
1700472963
1700472964
public void run(){
1700472965
1700472966
System.out.println(“电梯上下运行起来……”);
1700472967
1700472968
}
1700472969
1700472970
//电梯停止
1700472971
1700472972
public void stop(){
1700472973
1700472974
System.out.println(“电梯停止了……”);
1700472975
1700472976
}
1700472977
1700472978
}
1700472979
1700472980
电梯的开、关、运行、停都实现了,再看看场景类是怎么调用的,如代码清单26-3所示。
1700472981
1700472982
代码清单26-3 场景类
1700472983
1700472984
public class Client{
1700472985
1700472986
public static void main(String[]args){
1700472987
1700472988
ILift lift=new Lift();
1700472989
1700472990
//首先是电梯门开启,人进去
1700472991
1700472992
lift.open();
1700472993
1700472994
//然后电梯门关闭
1700472995
1700472996
lift.close();
1700472997
1700472998
//再然后,电梯运行起来,向上或者向下
1700472999
1700473000
lift.run();
1700473001
1700473002
//最后到达目的地,电梯停下来
1700473003
1700473004
lift.stop();
1700473005
1700473006
}
1700473007
1700473008
}
1700473009
[
上一页 ]
[ :1.70047296e+09 ]
[
下一页 ]