Question: Use the Observer Pattern to improve the code in Observer.cpp so that: 1 ) . Make People and Organization to be observers / listeners /
Use the Observer Pattern to improve the code in Observer.cpp so that:
Make People and Organization to be observerslistenerssubscribers
Make FireDept and PoliceDept to be subjectsposterspublishers
People and Organization objects can subscribe themselves to either FireDept or PoliceDept or both at run time.
FireDept and PoliceDept objects can send alarm messages to all their subscribers as run time.
Clients can always create and subscribe more People and Organization objects to FireDept and PoliceDept objects at run time.
In the client code the main function create a FireDept object and a PoliceDept object.
Create a People object named Ken that subscribes to the FireDept object. Create a People object named Mary that subscribes to the PoliceDept
object.
Create an Organization object named CSUSM that subscribes to both the FireDept object and the PoliceDept object.
Let both the FireDept object and the PoliceDept object broadcast alarm messages to their subscribers.
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
