25-Comp-A6 Software Engineering · May 2015
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
National Exams — May 2015 — 98-Comp-A6 Software Engineering. Three-hour, closed-book exam, no calculator permitted. Format: eight questions, candidates answer any five (all questions equal weight — each of the five counted questions is worth 20%; only the first five questions as they appear in the answer book are marked). All eight questions are solved below for completeness.
Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, function-oriented and object-oriented design, software testing, distributed software engineering, real-time software engineering, reliability engineering, verification and validation; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process/testing coverage; Coulouris, Dollimore, Kindberg & Blair, Distributed Systems: Concepts and Design — scalability, distributed objects, client-server architectures.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Applying the standard noun-extraction heuristic to the problem description (entry/smoke/temperature/flood sensors, alarms, lights, phone numbers, keypad, thresholds, delays) and merging duplicates gives an abstract Sensor class with four concrete subclasses (one per sensor type, sharing a common polling/threshold interface), a coordinating SecuritySystem object that holds the armed/disarmed state and owns a Configuration object (thresholds, phone numbers, delays), a Keypad object for owner interaction, and three independent output/actuator objects (AlarmController, LightController, PhoneDialer).
SecuritySystem is the coordinating object: it holds the current arm state (Armed/Disarmed), owns the Configuration, and its handleEvent() operation is invoked whenever any sensor reports an event, applying the configured threshold/delay logic before deciding whether to trigger an alarm. Sensor is an abstract base class defining a common poll() interface returning a SensorEvent; EntrySensor, SmokeSensor, TemperatureSensor and FloodSensor are its concrete subclasses, each knowing only how to read its own physical transducer and compare against its own threshold — polymorphism lets SecuritySystem treat every sensor type uniformly through the common interface rather than needing a type-specific branch for each. Keypad handles owner interaction (PIN entry to arm/disarm, and PIN-gated access to programming mode) and writes new thresholds, phone numbers and delays into Configuration, which is simply a structured store of the owner-settable parameters, decoupled from both the sensors that read it and the keypad that writes it. AlarmController, LightController and PhoneDialer are independent output objects, each responsible for exactly one physical actuation (sounding/silencing the siren; turning on the selected light zone; dialling the owner's programmed numbers in sequence) and each triggered only by SecuritySystem, never directly by a sensor — this keeps the decision of whether and how to respond to an event in one place.