Object-Oriented Design and Programming Tutorial
Consider a security system for protecting residential properties:
• Several security guards may be assigned to protect a property.
• Motion detectors can be installed to monitor particular areas within a property.
Each motion detector is associated with a location description that describes the
area monitored by that motion detector.
• A motion detector activates when it detects movement. When this happens, an
alert message including the location description of the motion detector is sent to
all security guards assigned to protect the corresponding property.
You may assume the availability of the following template class:
template
class List {
…
public:
void append(const T &item); // append item to list
void remove(const T &item); // delete item from list
int size(); // number of list items
T *front(); // pointer to first list item
T *next(); // pointer to subsequent list item(s)
};
a Draw a UML class diagram to describe the above.
b Write C++ class declarations (i.e. no function bodies) to support the above.
c Write a test function as follows:
– Kensington Palace is a property fitted with three motion detectors having
location descriptions “Hallway East”, “Hallway West” and “Crown Jewels
Display Case” respectively.
– Imperial College is a property fitted with a single motion detector having
location description “Rector’s Office”.
– Alice and Bob are security guards who are assigned to protect Kensington
Palace.
– The “Hallway East” motion detector activates.
– Alice is assigned to protect Imperial College.
– The “Crown Jewels Display Case” motion detector activates.
d Write the bodies of the functions from part (b).