-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses_task.py
More file actions
93 lines (78 loc) · 2.43 KB
/
classes_task.py
File metadata and controls
93 lines (78 loc) · 2.43 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
import datetime
class Employee(object):
def __init__(self, name, age, salary, employment_date):
self.name = name
self.age = age
self.salary = salary
self.employment_date = employment_date
datetime_object = datetime.datetime.now()
def get_working_years(self):
datetime_object = datetime.datetime.now()
return int(datetime_object.year) - int(self.employment_date)
def printI(self):
print("name: "+self.name+", age: "+str(self.age)+", salary: "+str(self.salary)+", working years: "+str(self.get_working_years()))
class Manager(Employee):
def __init__(self, name, age, salary, employment_date,bonus_percentage):
self.name = name
self.age = age
self.salary = salary
self.employment_date = employment_date
self.bonus_percentage = bonus_percentage
datetime_object = datetime.datetime.now()
def get_working_years(self):
datetime_object = datetime.datetime.now()
return int(datetime_object.year) - int(self.employment_date)
def get_bonus(self):
return float(self.bonus_percentage) * int(self.salary)
def printI(self):
print("name: "+self.name+", age: "+str(self.age)+", salary: "+str(self.salary)+", working years: "+str(self.get_working_years())+", bonus: "+str(self.get_bonus()))
e_list = []
m_list = []
print("Welcome to HR Pro 2019")
print("Choose an action to do:")
print(" 1. show employees")
print(" 2. show managers")
print(" 3. add an employee")
print(" 4. add a manager")
print(" 5. exit")
ch = input("what would you like to do?")
while int(ch) != 5:
print("-" * 20)
if int(ch) == 1:
print("Employees")
if not e_list:
print("There are no employees added yet.")
else:
for i in e_list:
i.printI()
print("-" * 20)
elif int(ch) == 2:
print("Managers")
if not m_list:
print("There are no managers added yet.")
else:
for i in m_list:
i.printI()
print("-" * 20)
elif int(ch) == 3:
name=input("name: ")
age=input("age: ")
salary=input("salary: ")
employment_date=input("employmement year: ")
emp= Employee(name,age,salary,employment_date)
e_list.append(emp)
print("Employee added succesfully")
elif int(ch)==4:
name=input("name: ")
age=input("age: ")
salary=input("salary: ")
employment_date=input("employmement year: ")
bonus=input("bonus percentage: ")
emp= Manager(name,age,salary,employment_date,bonus)
m_list.append(emp)
print("Employee added succesfully")
elif int(ch)==5:
break
else:
print("Invalid input.")
ch = input("what would you like to do?")