-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuntitled.py
More file actions
97 lines (48 loc) · 1.6 KB
/
untitled.py
File metadata and controls
97 lines (48 loc) · 1.6 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Employee:
raise_amount =0
num_of_emp = 0
def __init__ (self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = str.lower(first+'.'+last+'@company.com')
Employee.num_of_emp += 1
def fullname ( self ):
print ("{} {}".format(self.first,self.last))
def pay_raise (self):
self.pay = int(self.pay * self.raise_amount)
'''Inheritance'''
class Developer(Employee):
raise_amount = 0
pass
class Manager(Employee):
# MANAGERS ARE EMPLOYEES TOO, SO ALONG WITH ALL PROPERTIES FROM PARENT CLASS EMPLOYEES
# HERE WE PASS LIST AS EMPLOYESS, here we takke all the basic properties for emp object from Employee class
def __init__ (self, first, last, pay, employees= None):
super().__init__(first, last, pay)
if employees is None:
self.employees = []
else:
self.employees = employees
#ADD & REMOVE EMPLOYEE TO MANAGER SUPERVISION
def add_emp(self, emp):
if emp not in self.employees:
self.employees.append(emp)
def rem_emp(self, emp):
if emp in self.employees:
self.employees.remove(emp)
# print the managers list
def emp_list(self):
for emp in self.employees:
print (emp.fullname())
# Employees
emp1= Developer("faisal", "khan", 20000)
emp2 = Developer('Test', "user", 4000)
emp3 = Employee ('ali','khna',2000)
#print ( "this is the email of emp1: {0} \nthis is the email of Employee 2: {1}".format(emp1.email, emp3.email) )
# Managers
mgr1= Manager("AADIL","KHAN", 9000, [emp1])
mgr1.add_emp(emp2)
#print(mgr1.emp_list())
mgr1.rem_emp(emp1)
print("__________", '\n',mgr1.emp_list(), '_________')