-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
24 lines (21 loc) · 887 Bytes
/
Client.java
File metadata and controls
24 lines (21 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package org.fade.pattern.bp.command;
/**
* 命令模式
* 客户端
* @author fade
* */
public class Client {
public static void main(String[] args) {
Light light = new Light();
LightOnCommand lightOnCommand = new LightOnCommand(light);
LightOffCommand lightOffCommand = new LightOffCommand(light);
RemoteController remoteController = new RemoteController();
remoteController.setCommands(0,lightOnCommand,lightOffCommand);
System.out.println("----------按下遥控器上打开灯的开关----------");
remoteController.onOpenButtonPushed(0);
System.out.println("----------按下遥控器上关闭灯的开关----------");
remoteController.onCloseButtonPushed(0);
System.out.println("----------按下遥控器上的撤销开关----------");
remoteController.onUndoButtonPushed();
}
}