-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPolyMorphism.py
73 lines (56 loc) · 1.67 KB
/
PolyMorphism.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
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
class Employee:
def __init__(self, name, Id, salary):
super().__init__()
self.name = name
self.Id = Id
self.salary = salary
def display(self):
print("Id:", self.Id)
print("Name:", self.name)
print("Salry:", self.salary)
def increment(self):
self.salary += (self.salary * 0.3)
class Developer(Employee):
def __init__(self, name, Id, salary, deskId):
super().__init__(name, Id, salary)
self.deskId = deskId
def display(self):
super().display()
print("Desk Id:", self.deskId)
class Manager(Employee):
def __init__(self, name, Id, salary, cabinId):
super().__init__(name, Id, salary)
self.cabinId = cabinId
def display(self):
super().display()
print("Cabin Id:", self.cabinId)
class Company:
def __init__(self, name, employees):
super().__init__()
self.name = name
self.employees = employees
def display(self):
print("Company Name:", self.name)
self.show_list_employees()
def show_list_employees(self):
for emp in self.employees:
print("Type:", type(emp))
emp.display()
def promote_all(self):
for emp in self.employees:
print("Type:", type(emp))
emp.increment()
dev1 = Developer("ABC", 1, 10000, 101)
dev2 = Developer("XYZ", 2, 12000, 102)
man1 = Manager("PQR", 3, 20000, 103)
man2 = Manager("LMN", 4, 30000, 104)
# dev1.display()
# dev2.display()
# man1.display()
# man2.display()
# dev1.increment()
# dev1.display()
com1 = Company("CODEKUL", [dev1, dev2, man1, man2])
com1.display()
com1.promote_all()
com1.display()