-
Notifications
You must be signed in to change notification settings - Fork 0
/
classex.py
71 lines (43 loc) · 1.63 KB
/
classex.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
class Employee:
raise_amt = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.email = first + '.' + last + '@email.com'
self.pay = pay
def fullname(self):
return ("{} {}").format(self.first, self.last)
def apply_raise(self):
self.pay = int(self.pay * self.raise_amt)
def __repr__(self):
return "Employee('{}', '{}', {})".format(self.first, self.last, self.pay)
def __str__(self):
return '{} - {}'.format(self.fullname(), self.email)
class Developer(Employee):
raise_amt = 1.10
def __init__(self, first, last, pay, prog_lang):
super().__init__(first, last, pay)
self.prog_lang = prog_lang
class Manager(Employee):
def __init__(self, first, last, pay, employees=None):
super().__init__(first, last, pay)
if employees is None:
self.employees = []
else:
self.employees = employees
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 print_emps(self):
for emp in self.employees:
print('--->',emp.fullname())
emp_1 = Employee('Corey', 'Schffer', 50000,'Python')
emp_2 = Employee('Test', 'Employee', 60000, 'Java')
print(emp_1.__repr__())
print(emp_1.__str__())
#dev_1 = Developer('Corey', 'Schffer', 50000,'Python')
#dev_2 = Developer('Test', 'Employee', 60000, 'Java')
#mgr_1 = Manager('Sue', 'Smith', 90000, [dev_1])