We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c275a96 commit 7b2f4c8Copy full SHA for 7b2f4c8
chapter06_command/remote_undo.py
@@ -0,0 +1,41 @@
1
+import abc
2
+
3
4
+class Command(abc.ABC):
5
+ def execute(self):
6
+ raise NotImplementedError
7
8
+ def undo(self):
9
10
11
12
+class NoCommand(Command):
13
14
+ pass
15
16
17
18
19
20
+class LightOnCommand(Command):
21
+ def __init__(self, light):
22
+ self.light = light
23
24
25
+ self.level = self.light.getLevel()
26
+ self.light.on()
27
28
29
+ self.light.dim(self.level)
30
31
32
+class LightOffCommand(Command):
33
34
35
36
37
38
+ self.light.off()
39
40
41
0 commit comments