Edit Sp02 Final Exam Review: Displaying Alarm Status here.
The classes that might be needed are
AlarmSystem which represents the alarm system. It is made up of messageHandler and a collection of alarms. It knows how to armAlarms, disarmAlarms, and tell the message handler to notify it's contacts.
Alarm: this class will hold general info on alarms. It will have a sound and functionality to turn it on and off.
IntruderAlarm is a specialization of Alarm with intruder alarm specific information. It knows how to trigger an intruder alarm.
FireAlarm is a specialization of Alarm which knows how to turn on sprinklers.
Sprinkler represents the sprinklers in the system. They know how to be turned on and off.
AlarmSound stores the sound of the alarm it also knows how to turn it on and off.
MessageHandler knows how to alert its contacts by email or telephone when an alarm goes off. It has a list of contacts to notify for specific alarms.
Contact this class stores the name, the alarm to contact for, the phone number, and the email address of a person to contact when the alarm goes off.
The Gen-Spec relationships are between Alarm, FireAlarm, and IntruderAlarm. The part-whole relationships are between the AlarmSystem, Alarm and MessageHandler.
To implement model/view communication I would have to create a new class AlarmView which handled all of the functionallity for displaying the status of the alarms. The communication between AlarmSystem and AlarmView would be done utilizing the principles of MVC. In the initialization of the AlarmSystem class I would add AlarmView as a dependent( self addDependent: AlarmView).
In order to do this I would have to make a few changes to the design. I would want to add an attribute to the Alarm class called vicinity that tells you were the alarm is located. Then you would have to make the AlarmSystem dependent on the alarms. So when an alarm is triggered a changed method is sent to AlarmSystem. Then it has to figure out which alarm has gone off. Once it has done this it changes the attributes for that particular alarm, and signals the AlarmView that there has been a change in the AlarmSystem status. The AlarmView will then update everything that it needs to on the view. Eric Soto
Nice job, Eric. More could be said on the last paragraph. What are the MVC issues here, e.g., "has to figure out which alarm has gone off."? Mark Guzdial
a view can be dependent on its model, then the model is responsible for announcing that it has changed a specific aspect of itself, and dependent view(s) are asked if they would like to update based on what aspect changed ellie