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:
1). Make People and Organization to be observers/listeners/subscribers.
2). Make FireDept and PoliceDept to be subjects/posters/publishers.
3). People and Organization objects can subscribe themselves to either FireDept or PoliceDept or both at run time.
4). FireDept and PoliceDept objects can send alarm messages to all their subscribers as run time.
5). Clients can always create and subscribe more People and Organization objects to FireDept and PoliceDept objects at run time.
6). 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 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!