-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoteLoader.cpp
More file actions
53 lines (41 loc) · 1.56 KB
/
remoteLoader.cpp
File metadata and controls
53 lines (41 loc) · 1.56 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
#include "CeilingFan.hpp"
#include "CeilingFanHighCommand.hpp"
#include "CeilingFanMediumCommand.hpp"
#include "CeilingFanLowCommand.hpp"
#include "CeilingFanOffCommand.hpp"
#include "Light.hpp"
#include "LightOnCommand.hpp"
#include "LightOffCommand.hpp"
#include "RemoteControlWithUndo.hpp"
#include <iostream>
int main()
{
auto remoteControl = RemoteControlWithUndo();
auto livingRoomLight = Light("Living Room");
auto livingRoomLightOn = LightOnCommand(&livingRoomLight);
auto livingRoomLightOff = LightOffCommand(&livingRoomLight);
remoteControl.setCommand(0, &livingRoomLightOn, &livingRoomLightOff);
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
std::cout << remoteControl << '\n';
remoteControl.undoButtonWasPushed();
remoteControl.offButtonWasPushed(0);
remoteControl.onButtonWasPushed(0);
std::cout << remoteControl << '\n';
remoteControl.undoButtonWasPushed();
std::cout << "\n*** Using State for Undo ***\n";
auto ceilingFan = CeilingFan("Living Fan");
auto ceilingFanMedium = CeilingFanMediumCommand(&ceilingFan);
auto ceilingFanHigh = CeilingFanHighCommand(&ceilingFan);
auto ceilingFanOff = CeilingFanOffCommand(&ceilingFan);
remoteControl.setCommand(0, &ceilingFanMedium, &ceilingFanOff);
remoteControl.setCommand(1, &ceilingFanHigh, &ceilingFanOff);
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
std::cout << remoteControl << '\n';
remoteControl.undoButtonWasPushed();
remoteControl.onButtonWasPushed(1);
std::cout << remoteControl << '\n';
remoteControl.undoButtonWasPushed();
return 0;
}