Hi All,
I have come across the following question in mock exam.
You have been asked to create a scheduling system for a hotel and catering organsiation.
You have been given the following information and asked to create a set of classes to represent
it.
On the catering side of the organsiation they have
Head Chefs
Chefs
Apprentice Chefs
The system needs to store an employeeid, salary and the holiday entitlement
How would you best represent this information in Javae been given the following information and
asked to create a set of classes to represent it.
How would you best represent this information in
Java 1) Create classes for Head Chef, Chef, Apprentice Chef and store the other values in fields
2) Create an employee class and derive sub classes for Head Chef, Chef, Apprentice Chef and store
the other values in fields.
3) Create and employee class with fields for Job title and fields for the other values.
4) Create classes for all of the items mentioned and create a container class to represent employees
I answered this with option 2 as all are employees and there may be different responsibilities to HeadChef, Chef and Apprentice and those could be written as methods in respective classes.
But the answer is 3. Anybody please explain how the 3rd option is better than 2nd?