-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
61 lines (48 loc) · 2.44 KB
/
Program.cs
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
using System;
namespace Command
{
class Program
{
static void Main(string[] args)
{
RemoteControl remote = new RemoteControl();
Light livingRoomLight = new Light();
Stereo stereo = new Stereo();
CeilingFan ceilingFan = new CeilingFan("Living Room");
LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
StereoOnCommand stereoOn = new StereoOnCommand(stereo);
StereoOffCommand stereoOff = new StereoOffCommand(stereo);
CeilingFanHighCommand ceilingFanHigh = new CeilingFanHighCommand(ceilingFan);
CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
CeilingFanLowCommand ceilingFanLow = new CeilingFanLowCommand(ceilingFan);
CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(ceilingFan);
Console.WriteLine(remote.ToString());
remote.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
remote.SetCommand(1, stereoOn, stereoOff);
remote.SetCommand(2, ceilingFanHigh, ceilingFanOff);
remote.SetCommand(3, ceilingFanMedium, ceilingFanOff);
remote.SetCommand(4, ceilingFanLow, ceilingFanOff);
Console.WriteLine(remote.ToString());
//remote.OnButtonWasPushed(0);
//remote.OnButtonWasPushed(1);
//remote.OffButtonWasPushed(0);
//remote.OffButtonWasPushed(1);
//remote.UndoButtonWasPushed();
//remote.OnButtonWasPushed(2);
//remote.OnButtonWasPushed(3);
//remote.UndoButtonWasPushed();
//remote.OffButtonWasPushed(2);
//remote.UndoButtonWasPushed();
Command[] onCommands = { livingRoomLightOn, stereoOn, ceilingFanHigh };
MacroCommand macroCommandOn = new MacroCommand(onCommands);
Command[] offCommands = { livingRoomLightOff, stereoOff, ceilingFanOff };
MacroCommand macroCommandOff = new MacroCommand(offCommands);
remote.SetCommand(5, macroCommandOn, macroCommandOff);
remote.OnButtonWasPushed(5);
Console.WriteLine();
//remote.OffButtonWasPushed(5);
remote.UndoButtonWasPushed();
}
}
}