Payroll Program
Description
This program uses the OOP inheritance concept to design classes to represent different types of employees.The superclass Employee defines the common features that apply to any types of employees.
Data members: employee id, first and last names
constructors
getters and setters
earnings method (It is up to the subclasses how to implement it.)
toString method
constructors
getters and setters
earnings method (It is up to the subclasses how to implement it.)
toString method
The subclasses SalariedEmployee, HourlyEmployee, and CommissionEmployee inherit the superclass Employee's features and add additional features.
The subclass BasePlusCommissionEmployee inherits the superclass CommissionEmployee's features and adds additional features.
SalariedEmployee: fixed salary
HourlyEmployee: hours worked, and base wage
CommissionEmployee: sales and commission rate
BasePlusCommissionEmployee: base salary
HourlyEmployee: hours worked, and base wage
CommissionEmployee: sales and commission rate
BasePlusCommissionEmployee: base salary
In addition, all subclasses override the superclass' earnings() method.
The Employee's earnings() method simply returns 0. It is up to the subclasses how to implement it.
This problem was originally presented as an example in C++ HOW TO PROGRAM (2nd Edition) book.
Authors: Deitel & Deitel
The requirements are revised to meet our purpose.
Associated Concepts:
OOP - Inheritance
Algorithm:
Class diagrams:
Client program:
Client program:
The client program creates objects of different types of
employee.
It then prints these objects and uses the object references to call earnings() method.
It then prints these objects and uses the object references to call earnings() method.
Source Code
Superclass Employee classSubclass CommissionEmployee class
subclass BasePlusCommissionEmployee class
***Note: SalariedEmployee and HourlyEmployee source code were not provided.
Client program