Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An employee of a company. This is an abstract class. Only child classes should be instantiated. Public Attributes: - id _ :
An employee of a company.
This is an abstract class. Only child classes should be instantiated.
Public Attributes:
id: This employee's ID number.
name: This employee's name.
Private Attributes: add yours here
id: int
name: str
def initself id: int, name: str None:
Initialize this employee.
Note: This initializer is meant for internal use only;
Employee is an abstract class and should not be instantiated directly.
self.id id
self.name name
def getmonthlypaymentself float:
Return the amount that this Employee should be paid in one month.
Round the amount to the nearest cent.
raise NotImplementedError
def payself paydate: date None:
Pay this Employee on the given date and record the payment.
Assume this is called at most once per month.
payment self.getmonthlypayment
printfAn employee was paid payment on paydate
def totalpayself float:
Return the total amount of pay this Employee has received.
e SalariedEmployee 'Gilbert the cat',
epaydate
An employee was paid on
epaydate
An employee was paid on
epaydate
An employee was paid on
etotalpay
# TODO: implement this method! Youll need to add at least one
# instance attribute to this class to complete this method.
@checkcontracts
class SalariedEmployeeEmployee:
An employee whose pay is computed based on an annual salary.
Public Attributes:
salary: This employee's annual salary
Representation Invariants:
self.salary
id: int
name: str
salary: float
def initself id: int, name: str salary: float None:
Initialize this salaried Employee.
Preconditions:
salary
e SalariedEmployee 'Fred Flintstone',
esalary
Employee.initself id name
self.salary salary
def getmonthlypaymentself float:
Return the amount that this Employee should be paid in one month.
Round the amount to the nearest cent.
e SalariedEmployeeMr Slate',
egetmonthlypayment
return roundselfsalary
@checkcontracts
class HourlyEmployeeEmployee:
An employee whose pay is computed based on an hourly rate.
Public Attributes:
hourlywage:
This employee's hourly rate of pay.
hourspermonth:
The number of hours this employee works each month.
Representation Invariants:
self.hourlywage
self.hourspermonth
id: int
name: str
hourlywage: float
hourspermonth: float
def initself id: int, name: str hourlywage: float,
hourspermonth: float None:
Initialize this HourlyEmployee.
Preconditions:
hourlywage
hourspermonth
barney HourlyEmployee 'Barney Rubble',
barney.hourlywage
barney.hourspermonth
Employee.initself id name
self.hourlywage hourlywage
self.hourspermonth hourspermonth
def getmonthlypaymentself float:
Return the amount that this Employee should be paid in one month.
Round the amount to the nearest cent.
e HourlyEmployee 'Barney Rubble',
egetmonthlypayment
return roundselfhourspermonth self.hourlywage,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started