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 6011790 commit 495ff6aCopy full SHA for 495ff6a
chapter06_command/remote_undo.py
@@ -39,3 +39,28 @@ def execute(self):
39
40
def undo(self):
41
self.light.dim(self.level)
42
+
43
44
+class Light():
45
+ def __init__(self, location:str):
46
+ self.location = location
47
48
+ def on(self):
49
+ self.level = 100
50
+ print("Light is on")
51
52
+ def off(self):
53
+ self.level = 0
54
+ print("Light is off")
55
56
+ def dim(self, level):
57
+ self.level = level
58
+ if level == 0:
59
+ self.off()
60
+ else:
61
+ print(f"Light is dimmed to {self.level}%")
62
63
+ def get_level(self):
64
+ return self.level
65
66
0 commit comments