-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClient.java
More file actions
52 lines (37 loc) · 1.7 KB
/
Client.java
File metadata and controls
52 lines (37 loc) · 1.7 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package command;
/**
* @author Khalid Elshafie <abolkog@gmail.com>
* @created 14/03/2018.
*/
public class Client {
public static void main(String[] args) {
RemoteControl remoteControl = new RemoteControl();
Light light = new Light();
TurnOnLightCommand turnOnLightCommand = new TurnOnLightCommand(light);
TurnOffLightCommand turnOffLightCommand = new TurnOffLightCommand(light);
TV tv = new TV();
TurnOnTVCommand turnOnTVCommand = new TurnOnTVCommand(tv);
TurnOffTVCommand turnOffTVCommand = new TurnOffTVCommand(tv);
MusicPlayer musicPlayer = new MusicPlayer();
TurnOnMusicCommand turnOnMusicCommand = new TurnOnMusicCommand(musicPlayer);
TurnOffMusicCommand turnOffMusicCommand = new TurnOffMusicCommand(musicPlayer);
remoteControl.addCommand(0, turnOnLightCommand, turnOffLightCommand);
remoteControl.addCommand(1, turnOnTVCommand, turnOffTVCommand);
remoteControl.addCommand(2, turnOnMusicCommand, turnOffMusicCommand);
System.out.println(remoteControl);
System.out.println("------ Executing Commands ------");
remoteControl.onButtonPressed(0);
remoteControl.onButtonPressed(1);
remoteControl.offButtonPressed(0);
remoteControl.offButtonPressed(1);
remoteControl.onButtonPressed(2);
System.out.println("------ Undoing Commands ------");
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
remoteControl.undoButtonPressed();
}
}