Home‎ > ‎Assignments‎ > ‎

Payroll 5.0 - Employees Inherit and Morph

You have already worked with an Employee class in updating the Payroll Reporting program.  This time, structure your class so that you allow for three types of employees: salaried, hourly, and commission.
  • Salaried employees have an annual salary and are paid a fixed amount each week.
  • Hourly employees are paid at a particular rate by the number of hours worked.  They receive time-and-a-half overtime pay for the hours they work that exceed 40 hours (in a week).
  • Commission employees are paid a commission which is a percentage of their sales.
Your program should use a menu system for data input, with the following choices:
  • Enter employee data. Note that this choice will require that the program read in different data for the different types of employees. 
  • Print Report. Presumably this choice is invoked when all employee data have been input and pay calculated.
  • Exit the system. [Optional]
Inheritance.  You've probably already figured out that you will create an Employee base class and then three derived classes, one for each employee type.  Think about what attributes and methods all Employees may have in common, and which must be different for the different types of employees.

Polymorphism.  All three types of employees should have a method called WeeklyPay() to calculate the weekly pay (duh!) for employees of that type.  The method will be implemented differently in each of the three derived classes of Employee.

Part B (advanced) - How can you make the WeeklyPay() method more truly polymorphic? (Hint: Try using virtual functions.)