Design and implement a class hierarchy for any organization, employees. We are interested in modeling only the Managers and Faculty. Director shall be treated as a Manager. The following information for each employee needs to be captured:
This is the sort of problem usually given to 1st-year students.
Not to say that means it's a total no-brainer, but come on, do a bit of reading! you've been given all the information on a nice big round plate, you just need to work those brain cells a little to seperate it out.
First Name, Middle Initial, and Last Name
All of above are of type string except Middle Initial that is of type Character.
Have you done any database work? Imagine you are setting up an MS Access database, you will find the data relationship diagram is just the same! You've just been given 3 field names (variables) here... field names/variables are like
attributes of your Objects (in this case, Objects are people..)
All Managers belong to certain Level which are numbered 3 through 5 and
all managers must belong to one of the university department (a string).
Director, though Manager, does not belong to any level and also does not belong
to any department. Each faculty member is either professor, Associate or
Assistant Professor and belongs to some department.
Here are more fields/attributes.. and also clues as to what sort of classes/people you should be thinking about..
We are only interested in creating objects of different types of employees
(i.e. Managers, Faculty Members, or Director) and to print the relevant
information for each employee in the following format.
OK.. break it down a little.. use a pen & paper to list all your different types of people, and all your types of attributes..
for Manager the output of function should be of the form:
First Name, Middle Initil, Last Name Department Level
for Director the output of function should be of the form:
First Name, Middle Initil, Last Name “Director�
for Faculty the output of function should be of the form:
First Name, Middle Initil, Last Name Department Position
Again, you've been given field names on a plate! see if you can link attributes and people together on paper, this will be the beginning of your class diagram
a) Show a complete class diagram against the system described above.
b) Implement Manager and Director Classes described in the class diagram above.
c) Implement a global non-template method PrintDetail() that accepts any kind of university employee and print all its relevant details.
and here you have been given a Method/Function.. but worry about that later, you need to get your data diagram sorted on paper, else you'll be going nowhere fast.. You'll be surprised how simple the problem is once you have a visual aid.
So, which field names are common to all your classes? these 'common' attributes will be inside your base class.. and inherited by the derived classes.
(HINT - in a good system, data shouldn't be dupilicated anywhere unnecessarily)