-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRemoteLoader.java
More file actions
102 lines (82 loc) · 3.58 KB
/
RemoteLoader.java
File metadata and controls
102 lines (82 loc) · 3.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package command;
import command.impl.CeilingFanHighCommand;
import command.impl.CeilingFanMediumCommand;
import command.impl.CeilingFanOffCommand;
import command.impl.CeilingFanOnCommand;
import command.impl.GarageDoorDownCommand;
import command.impl.GarageDoorUpCommand;
import command.impl.LightOffCommand;
import command.impl.LightOnCommand;
import command.impl.MacroCommand;
import command.impl.StereoOffWithCDCommand;
import command.impl.StereoOnWithCDCommand;
/**
* Created by http://teachcourse.cn on 2018/03/22.
*/
public class RemoteLoader {
public static void main(String[] args) {
RemoteControl remoteControl = new RemoteControl();
Light livingRoomLight = new Light("Living Room");
Light kitchenLight = new Light("Kitchen");
CeilingFan ceilingFan = new CeilingFan("Living Room");
GarageDoor garageDoor = new GarageDoor("");
Stereo stereo = new Stereo("Living Room");
LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
LightOffCommand livingRoomLightOff = new LightOffCommand(
livingRoomLight);
LightOnCommand kitchenLightOn = new LightOnCommand(kitchenLight);
LightOffCommand kitchenLightOff = new LightOffCommand(kitchenLight);
CeilingFanOnCommand ceilingFanOn = new CeilingFanOnCommand(ceilingFan);
CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(
ceilingFan);
CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(
ceilingFan);
CeilingFanHighCommand ceilingFanHigh = new CeilingFanHighCommand(
ceilingFan);
GarageDoorUpCommand garageDoorUp = new GarageDoorUpCommand(garageDoor);
GarageDoorDownCommand garageDoorDown = new GarageDoorDownCommand(
garageDoor);
StereoOnWithCDCommand stereoOnWithCD = new StereoOnWithCDCommand(stereo);
StereoOffWithCDCommand stereoOffWithCD = new StereoOffWithCDCommand(
stereo);
remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);
remoteControl.setCommand(1, kitchenLightOn, kitchenLightOff);
remoteControl.setCommand(2, ceilingFanOn, ceilingFanOff);
remoteControl.setCommand(3, stereoOnWithCD, stereoOffWithCD);
remoteControl.setCommand(4, garageDoorUp, garageDoorDown);
remoteControl.setCommand(5, ceilingFanMedium, ceilingFanOff);
remoteControl.setCommand(6, ceilingFanHigh, ceilingFanOff);
System.out.println(remoteControl);
remoteControl.toString();
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(1);
remoteControl.offButtonWasPushed(1);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(2);
remoteControl.offButtonWasPushed(2);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(3);
remoteControl.offButtonWasPushed(3);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(4);
remoteControl.offButtonWasPushed(4);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(5);
remoteControl.offButtonWasPushed(5);
remoteControl.undoButterWasPushed();
remoteControl.onButtonWasPushed(6);
remoteControl.offButtonWasPushed(6);
remoteControl.undoButterWasPushed();
Command[] partyOn = { livingRoomLightOn, kitchenLightOn, ceilingFanOn,
garageDoorUp, stereoOnWithCD };
Command[] partyOff = { livingRoomLightOff, kitchenLightOff,
ceilingFanOff, garageDoorDown, stereoOffWithCD };
MacroCommand partyOnMarcro = new MacroCommand(partyOn);
MacroCommand partyOffMarcro = new MacroCommand(partyOff);
remoteControl.setCommand(0, partyOnMarcro, partyOffMarcro);
remoteControl.onButtonWasPushed(0);
remoteControl.undoButterWasPushed();
}
}