-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCeilingFanHighCommand.hpp
50 lines (45 loc) · 997 Bytes
/
CeilingFanHighCommand.hpp
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
#ifndef CEILING_FAN_HIGH_COMMAND_H
#define CEILING_FAN_HIGH_COMMAND_H
#include "CeilingFan.hpp"
#include "Command.hpp"
#include <string>
class CeilingFanHighCommand : public Command {
public:
CeilingFanHighCommand(CeilingFan *cf) : ceilingFan(cf) { }
void execute() override;
void undo() override;
std::string getClassName() const override { return className; };
private:
CeilingFan *ceilingFan;
CeilingFan::Speed prevSpeed;
std::string className = "CeilingFanHighCommand";
};
inline
void
CeilingFanHighCommand::execute()
{
prevSpeed = ceilingFan->getSpeed();
ceilingFan->high();
}
inline
void
CeilingFanHighCommand::undo()
{
switch (prevSpeed) {
case CeilingFan::Speed::HIGH:
ceilingFan->high();
break;
case CeilingFan::Speed::MEDIUM:
ceilingFan->medium();
break;
case CeilingFan::Speed::LOW:
ceilingFan->low();
break;
case CeilingFan::Speed::OFF:
ceilingFan->off();
break;
default:
break;
}
}
#endif /* CEILING_FAN_HIGH_COMMAND_H */