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 times their hourly salary rate for all hours worked in excess of hours.The company wants to implement an app that performs its payroll calculations polymorphically.EmployeeUML.jpgkeyboardarrowdownEmployee 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.NameMangled 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.keyboardarrowdownSalariedEmployeeMethodsAn 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 readwrite weeklysalary property in which the setter ensures that the property is always nonnegative.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 strkeyboardarrowdownHourlyEmployeeThis 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.Readwrite hours and wages properties in which the setters ensure thatthe hours are in range and wage per hour is always nonnegative.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.keyboardarrowdownTesting 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
