-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathremoteLoader.cpp
More file actions
54 lines (46 loc) · 1.67 KB
/
Copy pathremoteLoader.cpp
File metadata and controls
54 lines (46 loc) · 1.67 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
#include "CeilingFan.hpp"
#include "CeilingFanOnCommand.hpp"
#include "CeilingFanOffCommand.hpp"
#include "GarageDoor.hpp"
#include "GarageDoorUpCommand.hpp"
#include "GarageDoorDownCommand.hpp"
#include "Light.hpp"
#include "LightOnCommand.hpp"
#include "LightOffCommand.hpp"
#include "RemoteControl.hpp"
#include "Stereo.hpp"
#include "StereoOnWithCDCommand.hpp"
#include "StereoOffCommand.hpp"
#include <iostream>
int main()
{
// Invoker
auto remoteControl = RemoteControl();
// Receivers
auto livingRoomLight = Light("Living Room");
auto kitchenLight = Light("Kitchen Light");
auto ceilingFan = CeilingFan("Living Room");
auto garageDoor = GarageDoor();
auto stereo = Stereo("Living Room");
// Commands
auto livingRoomLightOn = LightOnCommand(&livingRoomLight);
auto livingRoomLightOff = LightOffCommand(&livingRoomLight);
auto kitchenLightOn = LightOnCommand(&kitchenLight);
auto kitchenLightOff = LightOffCommand(&kitchenLight);
auto ceilingFanOn = CeilingFanOnCommand(&ceilingFan);
auto ceilingFanOff = CeilingFanOffCommand(&ceilingFan);
auto garageDoorUp = GarageDoorUpCommand(&garageDoor);
auto garageDoorDown = GarageDoorDownCommand(&garageDoor);
auto stereoOnWithCD = StereoOnWithCDCommand(&stereo);
auto stereoOff = StereoOffCommand(&stereo);
remoteControl.setCommand(0, &livingRoomLightOn, &livingRoomLightOff);
remoteControl.setCommand(1, &kitchenLightOn, &kitchenLightOff);
remoteControl.setCommand(2, &ceilingFanOn, &ceilingFanOff);
remoteControl.setCommand(3, &stereoOnWithCD, &stereoOff);
std::cout << remoteControl << '\n';
for (Command::cvec_size i = 0; i < 4; ++i) {
remoteControl.onButtonWasPushed(i);
remoteControl.offButtonWasPushed(i);
}
return 0;
}