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 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 roledepartment is changed, an update notification should be sent to all observers eg 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 roledepartment
HINT
ObservableEmployeeList employeeList new ObservableEmployeeList;
employeeList.addObservernew HRDepartmentObserver;
employeeList.addObservernew ManagerObserver;
employeeList.addEmployeenew 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 thirdparty system you need to adapt
Implement an ExternalSalaryAdapter class that adapts this thirdparty class to work with your existing Compensable interface.
The ExternalSalaryAdapter should implement the calculateTotalCompensation method to adapt the thirdparty logic and make it compatible with your current system.
HINT
ExternalSalaryCalculator externalCalculator new ExternalSalaryCalculator;
System.out.printlnAdapter new ExternalSalaryAdapterexternalCalculator;
System.out.printlnTotal 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
