Need help in visualizing the hierarchy...

Apr 27, 2014 at 8:08am
Please read my problem. I am not asking for code.

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?

Here is the link: http://s28.postimg.org/qhy2i7bu5/Hierarchy.png

2 - In hourly, what does in round brackets mean? What is meant by "pays time and half"?

3 - In base-plus-commissioned, is it required to take "base salary" from user or I just get salary from the salaried employee?

I'll appreciate if anyone shares his/her thoughts.
Apr 27, 2014 at 8:18am
1. Base-plus-commissioned is also a Salaried.

2. Every hour worked after 40 hours counts as 80 minutes when calculating pay. I.e. overtime_pay = (hours - 40) * 3 * pay / 2.

3. I don't understand the question.
Apr 27, 2014 at 8:37am
@helios

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"!?

2 - Thanks a bunch!

3 - Forget this one. :D

Please reply for the first.
Last edited on Apr 27, 2014 at 8:38am
Apr 27, 2014 at 9:15am
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.
Apr 27, 2014 at 9:29am
Oh! Ok, Thanks.. And it solves my third question.
Last edited on Apr 27, 2014 at 9:32am
Apr 27, 2014 at 9:37am
BTW is the date class in the right place?
Topic archived. No new replies allowed.