-
Notifications
You must be signed in to change notification settings - Fork 12
/
oop.py
43 lines (35 loc) · 1.12 KB
/
oop.py
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
# OOP (Object Oriented Programming)
class TroubleTicket:
def __init__(self,
number,
symptom="",
severity="service_impacted",
urgency="P3",
mean_time=0
):
self.number = number
self.symptom = symptom
self.severity = severity
self.urgency = urgency
self.mean_time = mean_time
def __str__(self):
return f"#{self.number} {self.symptom}"
class PowerTicket(TroubleTicket):
# Constructor
def __init__(self, number):
self.power_type = "PPP"
# Call Parent or Base Class
super().__init__(number, symptom="power")
data = [
PowerTicket(123),
TroubleTicket(222, "power", "service_impacted", "P1"),
TroubleTicket(333, "transport", "service_impacted", "P1"),
TroubleTicket(333, "unknown", "service_impacted", "P1"),
]
for ticket in data:
if "power" == ticket.symptom:
print(f"email group one {ticket}")
elif "transport" == ticket.symptom:
print(f"email group two {ticket}")
else:
print(f"email group X {ticket}")