Question: You will implement 2 different patterns. First design pattern : Observer Pattern We would like to keep track of updates in the employee list. Whenever

You will implement 2 different patterns.
First design pattern :
Observer Pattern
We would like to keep track of updates in the employee list. Whenever a new employee is added, or their role/department is changed, an update notification should be sent to all observers (e.g., HR or department managers). You will create an observer mechanism to handle these updates.
Create an ObservableEmployeeList class that maintains the list of employees and notifies the observers when changes are made.
Implement the Observer interface and concrete observers such as HRDepartmentObserver and ManagerObserver.
The ObservableEmployeeList will notify observers of events such as employee addition or updates in role/department.
HINT
ObservableEmployeeList employeeList = new ObservableEmployeeList();
employeeList.addObserver(new HRDepartmentObserver());
employeeList.addObserver(new ManagerObserver());
employeeList.addEmployee(new Employee(...)); // This triggers a notification to all observers.
Second Design Pattern
Adapter Pattern
My favorite pattern to go with is the adapter pattern. I want you to integrate a new third party system
for salary calculation that doesn't follow your existing interface. To make it work within your existing application, you will implement the Adapter Pattern.
You will create an ExternalSalaryCalculator class (assume this is the third-party system you need to adapt).
Implement an ExternalSalaryAdapter class that adapts this third-party class to work with your existing Compensable interface.
The ExternalSalaryAdapter should implement the calculateTotalCompensation() method to adapt the third-party logic and make it compatible with your current system.
HINT
ExternalSalaryCalculator externalCalculator = new ExternalSalaryCalculator();
System.out.printlnAdapter = new ExternalSalaryAdapter(externalCalculator);
System.out.println("Total Compensation: "+ salaryAdapter.calculateTotalCompensation());
Submission:
Upload the following files:
person.java
Employee.java
Manager.java
BonusStrategy.java
ReportGenerator.java
EmployeeFactory.java
ObservableEmployeeList.java
HRDepartmentObserver.java
ManagerObserver.java
ExternalSalaryAdapter.java
To achieve bonus points
Add another (any) designer patternAdd another observer pattern

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!