-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.java
More file actions
31 lines (24 loc) · 717 Bytes
/
Copy pathmain.java
File metadata and controls
31 lines (24 loc) · 717 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
25
26
27
28
29
30
31
/**
* @author: Ly Tran Vinh
* @contact: [email protected]
* @content: Command Pattern
*/
import Concretes.LightOffCommand;
import Concretes.LightOnCommand;
import Interfaces.Command;
import Invokers.RemoteControl;
import Receivers.Light;
public class main {
public static void main(String[] args) {
Light light = new Light();
Command lightOn = new LightOnCommand(light);
Command lightOff = new LightOffCommand(light);
RemoteControl remote = new RemoteControl();
// Turn the light on
remote.setCommand(lightOn);
remote.pressButton();
// Turn the light off
remote.setCommand(lightOff);
remote.pressButton();
}
}