1700472943
1700472944
public class Lift implements ILift{
1700472945
1700472946
//电梯门关闭
1700472947
1700472948
public void close(){
1700472949
1700472950
System.out.println(“电梯门关闭……”);
1700472951
1700472952
}
1700472953
1700472954
//电梯门开启
1700472955
1700472956
public void open(){
1700472957
1700472958
System.out.println(“电梯门开启……”);
1700472959
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();
[
上一页 ]
[ :1.700472943e+09 ]
[
下一页 ]