-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
70 lines (58 loc) · 2.89 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
62
63
64
65
66
67
68
69
70
using System;
namespace Remote
{
//Client
class Program
{
static void Main(string[] args)
{
RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();
Light livingRoomLight = new Light("Living Room");
LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
remoteControl.redoButtonWasPushed();
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
remoteControl.offButtonWasPushed(0);
remoteControl.onButtonWasPushed(0);
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
CeilingFan ceilingFan = new CeilingFan("Living Room");
CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
CeilingFanHighCommand ceilingFanHigh = new CeilingFanHighCommand(ceilingFan);
CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(ceilingFan);
remoteControl.setCommand(1, ceilingFanMedium, ceilingFanOff);
remoteControl.setCommand(2, ceilingFanHigh, ceilingFanOff);
remoteControl.onButtonWasPushed(1);
remoteControl.redoButtonWasPushed();
remoteControl.offButtonWasPushed(1);
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
remoteControl.onButtonWasPushed(2);
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
GarageDoor garageDoor = new GarageDoor("Garage");
GarageDoorUpCommand garageDoorUp = new GarageDoorUpCommand(garageDoor);
GarageDoorDownCommand garageDoorDown = new GarageDoorDownCommand(garageDoor);
remoteControl.setCommand(3, garageDoorUp, garageDoorDown);
remoteControl.onButtonWasPushed(3);
Console.WriteLine(remoteControl);
remoteControl.redoButtonWasPushed();
remoteControl.offButtonWasPushed(3);
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
Stereo stereo = new Stereo("Living Room");
StereoOnWithCDCommand stereoOnWithCD = new StereoOnWithCDCommand(stereo);
StereoOffCommand stereoOff = new StereoOffCommand(stereo);
remoteControl.setCommand(4, stereoOnWithCD, stereoOff);
remoteControl.onButtonWasPushed(4);
remoteControl.redoButtonWasPushed();
remoteControl.offButtonWasPushed(4);
Console.WriteLine(remoteControl);
remoteControl.undoButtonWasPushed();
}
}
}