-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.py
More file actions
33 lines (26 loc) · 1.03 KB
/
employee.py
File metadata and controls
33 lines (26 loc) · 1.03 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
class Employee:
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
class SalaryEmployee(Employee):
def __init__(self, fname, lname, salary):
super().__init__(fname, lname)
self.salary = salary
def calculate_paycheck(self):
return self.salary/52
class HourlyEmployee(Employee):
def __init__(self, fname, lname, weekly_hours, hourly_rate):
super().__init__(fname, lname)
self.weekly_hours = weekly_hours
self.hourly_rate = hourly_rate
def calculate_paycheck(self):
return self.weekly_hours*self.hourly_rate
class CommissionEmployee(SalaryEmployee):
def __init__(self, fname, lname, salary, sales_num, com_rate):
super().__init__(fname, lname, salary)
self.sales_num = sales_num
self.com_rate = com_rate
def calculate_paycheck(self):
regular_salary = super().calculate_paycheck()
total_commission = self.sales_num*self.com_rate
return regular_salary + total_commission