Objective The objective of this lab is to explore the concept of push notification by implementing the Observer design pattern. We recommend that classes you create today be contained within the model...

Objective The objective of this lab is to explore the concept of push notification by implementing the Observer design pattern. We recommend that classes you create today be contained within the model subsystem. Instructions Branch Create a branch called Observer-Work from your master branch and switch to it. Commit your changes to GIT as you complete each section. Software Engineering: Observer Pattern Pg. 2 Observer & Subject Setup your Observer and Subject interfaces and implement your Subject class. • Your Notification function should have an enumerated parameter called ObserverEvent. Create this enumeration with 2 values called ACTIVATE and SUBJECT_DEATH. • The Subject must have a function for each of the following behaviors: Adding an Observer, removing an Observer, and broadcasting* an ObserverEvent to all Observers. • The Subject’s destructor should broadcast* the second value of the enumeration. * If you choose to use an iterator for looping through your data structure, be careful as the functions you call may invalidate your iterator. Concrete Children In order for the new interfaces to work, the Observer and Subject interfaces need to be inherited by their respective concrete child classes. • The StickyBomb class will inherit the Observer interface and override the Notification function. This class already exists in the model folder, you need to add it into the project. • The Enemy class will inherit the Subject interface. Integration Within the playerShip portion of the LevelState::CheckForInput function, add 2 new checks for input. • The first will launch a StickyBomb towards the enemy the cursor is hovering over when the ‘C’ key is pressed. This should consume 10 energy units from the ship’s battery, and only work when enough energy is available. It is suggested that you make a factory method for the creation portion of this code, but it is not required. • The second will explode all existing bombs by calling all Subjects’ NotifyObservers function when the ‘X’ key is pressed. Make sure to test both stuck and mid-flight detonation. Code Mapping Explore the StickyBomb code further by code-mapping each of its virtual functions. Save each diagram separately. Annotate what you feel are the most important functions by adding a note to each, explaining what it does in plain English. End Result Your finished code should have new behavior. You will have implemented the Observer pattern with a single event.
Sep 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here