Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prep 3 Synthesize = = = CSC 1 4 8 Winter 2 0 2 4 = = = Department of Mathematical and

"""Prep 3 Synthesize
=== CSC148 Winter 2024===
Department of Mathematical and Computational Sciences,
University of Toronto Mississauga
=== Module Description ===
This module contains an illustration of *inheritance* through an abstract
Employee class that defines a common interface for all of its subclasses.
"""
from datetime import date
class Employee:
"""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.
"""
id_: int
name: str
def __init__(self, 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 get_monthly_payment(self)-> float:
"""Return the amount that this Employee should be paid in one month.
Round the amount to the nearest cent.
"""
raise NotImplementedError
def pay(self, pay_date: date)-> None:
"""Pay this Employee on the given date and record the payment.
(Assume this is called once per month.)
"""
payment = self.get_monthly_payment()
print(f'An employee was paid {payment} on {pay_date}.')
def total_pay(self)-> float:
"""Return the total amount of pay this Employee has received.
>>> e = SalariedEmployee(14, 'Gilbert the cat', 1200.0)
>>> e.pay(date(2018,6,28))
An employee was paid 100.0 on 2018-06-28.
>>> e.pay(date(2018,7,28))
An employee was paid 100.0 on 2018-07-28.
>>> e.pay(date(2018,8,28))
An employee was paid 100.0 on 2018-08-28.
>>> e.total_pay()
300.0
"""

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

What is meant by an activity base when dealing with

Answered: 1 week ago

Question

8-6 Who poses the biggest security threat: insiders or outsiders?

Answered: 1 week ago