CASE STUDY
Using Inheritance to Create Related Employee Types:
we use an inheritance hierarchy containing types of employees in a company’s payroll app to demonstrate the relationship between a superclass and its subclass.
All employees of the company have a lot in common—for example, each has a name and gets paid—but commission employees (who will be represented as objects of a superclass) are paid a percentage of their sales, while base-salaried commission employees (who will be represented as objects of a subclass) receive a base salary plus a percentage of their sales.
First, we present the superclass CommissionEmployee. Next, we create a subclass BasePlusCommissionEmployee that inherits from classCommissionEmployee