-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock_class.py
More file actions
80 lines (58 loc) · 2.17 KB
/
clock_class.py
File metadata and controls
80 lines (58 loc) · 2.17 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'''
Create class Clock and it's subclass AlarmClock. Test clocks in main. There has to be ticking and alarming methods...
'''
class Clock:
def __init__(self, clock_type, material, color, price):
self.clock_type = clock_type #wristwatch, wall clock, grandfather clock, radio, cockoo clock, ...
self.material = material #wood, plastic, silver, gold ....
self.color = color
self.price = price
def getAll(self):
clock_info = f"CLOCK INFO:\nClock type: {self.clock_type} \nMaterial: {self.material} \nColor: {self.color} \nPrice: {self.price}€"
return clock_info
def getType(self):
return self.clock_type
def getMaterial(self):
return self.material
def getColor(self):
return self.color
def getPrice(self):
return self.price
def setType(self, clock_type):
self.clock_type = clock_type
def setMaterial(self, material):
self.material = material
def setColor(self, color):
self.color = color
def setPrice(self, price):
self.price = price
def ticking(self):
print("tic, tac, tic, tac.....")
class AlarmClock(Clock):
def __init__(self, manufacturer, origin):
self.manufacturer = manufacturer
self.origin = origin
def getAlarmInfo(self):
info = f"ALARM INFO:\nManufacturer: {self.manufacturer} \nOrigin: {self.origin}"
return info
def getManufacturer(self):
return self.manufacturer
def getRingTone(self):
return self.origin
def setManufacturer(self, manufacturer):
self.manufacturer = manufacturer
def setRingTone(self, origin):
self.origin = origin
def alarming(self):
print("RRRRRRRRIIIIIIINNGGGGGGGGG!!!!!!!!!!!")
my_clock = Clock("wall clock", "plastic", "blue", 14.99)
my_clock.ticking()
print(my_clock.getAll())
my_alarm = AlarmClock("Gallet & Co.", "Swiss")
print(my_alarm.getAlarmInfo())
my_alarm.alarming()
my_alarm.setPrice(900)
print(f"Price: {my_alarm.getPrice()}")
my_alarm.setMaterial("steel")
my_alarm.setColor("black")
print(f"Material: {my_alarm.getMaterial()}, \nColor: {my_alarm.getColor()}")