forked from realpython/materials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkers.py
More file actions
23 lines (18 loc) · 749 Bytes
/
Copy pathworkers.py
File metadata and controls
23 lines (18 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Worker:
def __init__(self, name, address, hourly_salary):
self.name = name
self.address = address
self.hourly_salary = hourly_salary
def show_profile(self):
print("== Worker profile ==")
print(f"Name: {self.name}")
print(f"Address: {self.address}")
print(f"Hourly salary: {self.hourly_salary}")
def calculate_payroll(self, hours=40):
return self.hourly_salary * hours
class Manager(Worker):
def __init__(self, name, address, hourly_salary, hourly_bonus):
super().__init__(name, address, hourly_salary)
self.hourly_bonus = hourly_bonus
def calculate_payroll(self, hours=40):
return (self.hourly_salary + self.hourly_bonus) * hours