I have been given a HW to write code for a payroll system. The base class would be Employee. There are four types of employees.
1 - Salaried (fixed salary, no matter the hours)
2 - Hourly (overtime [>40 hours] pays time and half)
3 - Commissioned (paid percentage of sales)
4 - Base-plus-commissioned (base salary + percentage of sales)
Also add a private data member birthDate (a Date object) and departmentCode, an int to class Employee.
Here is where I need help..
1 - Is the following hierarchy that I'm visualizing right? Or is a change needed?
1 - You mean "Base-plus-commissioned" comes under "Salaried" instead of "Commissioned"? But how, I mean I have checked another almost same type of program hierarchy from Deital's C++ How to Program 8/e and they have "Base-plus-commissioned" under "Commissioned"!?
You mean "Base-plus-commissioned" comes under "Salaried" instead of "Commissioned"?
I mean it comes under both.
If all operations that can be performed on an instance of type A can also be performed on an instance of type B, then B can be made a subtype of A.
* The pay of a Salaried employee does not depend on hours worked.
* The pay of a Base-plus-commissioned does not depend on hours worked.
* The pay of a Commissioned employee depends on sales made.
* The pay of a Base-plus-commissioned employee depends on sales made.