Stacks 3
Stacks 3
Stacks 3
@property
def name(self): #getter for name
return self._name
@name.setter
def name(self, name): #Setter for name
self._name = name
@property
def employee_id(self): #getter for Employee Id
return self._employee_id
@employee_id.setter
def name(self, employee_id): #Setter for Employee ID
self._employee_id = employee_id
def calculate_payment(self):
if self._pieces_completed > 200:
return self._pieces_completed * self._rate_per_piece + 100
else:
return self._pieces_completed * self._rate_per_piece
def display_result(self):
return f"{Employee.display_result(self)} \nPayment:
{self.calculate_payment()}"
class SalesEmployee:
def __init__(self, sales_amount, commission_rate):
self._sales_amount = sales_amount
self._commission_rate = commission_rate
def calculate_payment(self):
return self._hourly_rate * self._hours_worked
def display_result(self):
return f"{Employee.display_result(self)} \nPayment:
{self.calculate_payment()}"
def calculate_payment(self):
return (self._sales_amount * (self._commission_rate / 100)) +
self._base_salary
def display_result(self):
return f"{Employee.display_result(self)} \nPayment:
{self.calculate_payment()}"
employee_list = [
Employee("rods", 1234),
HourlyWorker("jap", 1234, 20, 12),
PieceWorker("Eunice", 1332, 20, 10),
# CommissionWorker("James", 14552, 21, 100, 50)
]