-
Notifications
You must be signed in to change notification settings - Fork 0
/
lessonn.py
88 lines (72 loc) · 2.59 KB
/
lessonn.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import datetime
class Employee:
raise_amt = 1.04
num_of_emps = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.email = first + '.' + last + '@email.com'
self.pay = pay
Employee.num_of_emps += 1
def fullname(self):
return '{} {}'.format(self.first, self.last)
def apply_raise(self):
self.pay = int(self.pay * self.raise_amt)
@classmethod
def change_raise_amt(cls, amt):
cls.raise_amt = amt
return cls.raise_amt
@classmethod
def Alter_constr(cls, data):
first, last, pay = data.split('-')
return cls(first, last, pay)
@staticmethod
def is_workday(day):
if day.weekday() == 5 or day.weekday() == 6:
return False
return True
def __add__(self, other):
print(self.fullname(), other.fullname())
return self.pay + other.pay
def __sub__(self, other):
print(self.fullname(), other.fullname())
return self.pay - other.pay
def __repr__(self):
return 'Employee({}, {}, {})'.format(self.first, self.last, self.pay)
def __str__(self):
return 'name is {}, surname is {} and salary is {}'.format(
self.first, self.last, self.pay
)
def __mul__(self, other):
return self.pay * other.pay
class Developer(Employee):
raise_amt = 1.09
def __init__(self, first, last, pay, prog_lang):
super().__init__(first, last, pay)
self.__prog_lang = prog_lang
def PrLang(self):
return self.__prog_lang
class Manager(Employee):
def __init__(self, first, last, pay, employees=None):
super().__init__(first, last, pay)
if employees == None: self.__employees = []
else: self.__employees = employees
def PrintEmps(self):
for emp in self.__employees:
print('-->', emp.fullname())
def Add_emp(self, emp):
if emp not in self.__employees:
self.__employees.append(emp)
def Remove_emp(self, emp):
if emp in self.__employees:
self.__employees.remove(emp)
def get_data(self):
return self.__employees
emp_1 = Employee('Corey', 'Askren', 58000)
emp_2 = Employee('Ben', 'Kerrel', 65000)
emp_3 = Employee('Rachel', 'Griffin', 75000)
date = datetime.date(2020, 4, 10)
dev_1 = Developer('Lincoln', 'Badger', 99000, 'Python')
dev_2 = Developer('Bernard', 'Show', 102000, 'C++')
mgr_1 = Manager('Tahir', 'Kurbanov', 130000, [dev_1])
print(mgr_1._Manager__employees)