In: Computer Science
Scenario to be used for question ::
XYZ holdings have many branches. Each branch has a name and is located in a different province. Each branch has several departments such as marketing, finance, sales and customer relations. For a department to exist there must be employees employed in each of the departments. An employee is either a permanent staff member or a temporary staff member. The difference between these two types of employees exist in the facts that permanent staff earns a fixed salary of $30 000 every month and has a medical aid benefit whereas temporary staff members has an hourly rate of $400 per hour and their monthly salary is dependent on the number of hours worked each month multiplied by their hourly rate. Temporary staff members also do not have a medical aid benefit. All employees, however, have a name, surname and employee number.
Answer all questions within this section based on the information contained in the scenario.
Q.1.1 Based on the information contained in the scenario, create a class diagram which will address/ contain the following elements:
Q.1.1.1 Five classes called Branch, Department, Employee, PermanentEmployee and TemporaryEmployee.
Q.1.1.2 An appropriate relationships between class Branch, Department and Employee.
Q.1.1.3 An appropriate relationship between Employee, PermanentEmployee and TemporaryEmployee.
Q.1.1.4 Two instance variables declared in class Branch as well as accompanying getter and setter methods for each instance variable.
Q.1.1.5 One instance variable declared in class Department as well as accompanying getter and setter methods for the instance variable.
Q.1.1.6 Three instance variables declared in class Employee as well as accompanying getter and setter methods for each instance variable.
Q.1.1.7 Two instance variables declared in class PermanentEmployee as well as appropriate getter and setter methods and a parameterized constructor.
Q1.1.8: Three instance variables declared in class TemporaryEmployee as well as appropriate getter and setter methods and a parameterized constructor
Q1.1.9: Each element must be indicated using the correct notation
ANSWER:
XYZ holdings have many branches. Each branch has a name and is located in a different province. Each branch has several departments such as marketing, finance, sales and customer relations. For a department to exist there must be employees employed in each of the departments.
The below figure shows the relationships between all the classes:
1.1.1) All classes are shown in the above figure
1.1.2) Branch and Department follow a relationship of composition (from Department to Branch). This means that a department always exists under a branch. If a branch ceases to exist, the departments will also cease to exist. However, this condition is not explicitly mentioned in the problem.
Department and Employee also follow a relationship of composition but in reverse. This means that a department always only because of its employees. If there are no employees, the departments will also cease to exist.
1.1.3) Relation between Employee and Permanent employee & Temporary employee is that of inheritance. This means that Permanent employee & Temporary employee inherit all attributes and methods of Employee class. They also have their own exclusive attributes and methods as well.
1.1.4) Shown in the attached figure.
1.1.5) Shown in the attached figure.
1.1.6) Shown in the attached figure.
1.1.7) Shown in the attached figure.
//PLEASE UPVOTE//