In a well-structured class hierarchy, a superclass is a generalisation of its subclasses. Arranging related classes into a class hierarchy is a good way to design an application to take advantage of re-use.
Given a branch location, information about the company’s employees, including their names and employee numbers and, for the branch workers, their hourly overtime rate.
We have noted that this implies three classes for the application:
Employee
The application needs to maintain information about the employees – their names and employee numbers.
BranchWorker
The application needs to maintain information about the branch workers – their hourly overtime rate.
Manager
This has to be a distinct class since managers are employees but they do not have an hourly overtime rate.
We can arrange these classes into the class hierarchy shown in Figure 2.3. Their attributes would be:
Observe carefully how the requirements state that BranchWorker has an additional attribute hourly overtime rate. This differentiates it from Manager. As a consequence, we can have class hierarchy where BranchWorker is a specialisation of Employee, distinct from Manager.
Note also that you would need to demonstrate your understanding of the concepts involved here. This means that in your answers for your exercises and assignments, you should not repeat the superclass attributes in its subclasses.