Question: ow , develop an Employee class hierarchy that begins with an abstract class, then uses polymorphism to perform payroll calculations for objects of two concrete

ow, develop an Employee class hierarchy that begins with an abstract class, then uses polymorphism to perform payroll calculations for objects of two concrete subclasses.Consider the following problem statement:A company pays its employees weekly.The employees are of two types.Salaried employees are paid a fixed weekly salary regardless of the number of hours worked.Hourly employees are paid by the hour and receive overtime pay (1.5 times their hourly salary rate) for all hours worked in excess of 40 hours.The company wants to implement an app that performs its payroll calculations polymorphically.EmployeeUML.jpgkeyboard_arrow_downEmployee classEnployee class attributes:Each employee has:a first namea last nameTaxpayer Registration Number.earnings methodthe specific earnings calculation depends on the employee's type.Enployee class methods:An init method that initializes the first name, last name and TRN number data attributes.Name-Mangled properties for the:first namelast nameTRN data attributes.An unimplemented earnings methoddef earnings: passSubclasses must implement their own earnings method.A str method that returns a string containing the first name, last name and TRN of the employee.keyboard_arrow_downSalariedEmployeeMethodsAn init method thatinitializes:the first namelast nameTRNweekly salary .The first three of these should be initialized by calling base class Employee's init method.A read-write weekly_salary property in which the setter ensures that the property is always non-negative.A str method that returns a string starting with 'SalariedEmployee:' and followed by all the information about a SalariedEmployee.This overridden method should call the Employee class' version of _str.keyboard_arrow_downHourlyEmployeeThis Employee subclass should override earnings to return an HourlyEmployee's earnings, based on the hours worked and wage per hourThe class also should include:An init method to initialize:the first namelast nameTRNhourswages.The first name, last name and Social Securitynumber should be initialized by calling base class Employee's init method.Read-write hours and wages properties in which the setters ensure thatthe hours are in range (0-168)and wage per hour is always non-negative.A str method that returns a string starting with 'HourlyEmployee:' and followed by all the information about a HourlyEmployee.This overridden method should call Employee's version.keyboard_arrow_downTesting your classesAssign objects of the concrete classes SalariedEmployee and HourlyEmployee to variables, then display each employee's string representation and earnings.Place the objects into a list, then iterate through the list and polymorphically process each object, displaying its string representation and earnings.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!