A. Follow the Actor-Role pattern, translate the following domain description into a UML class diagram. The important nouns (underlined) should be classes. The important verbs (italicized) should be associations. Be sure to include multiplicities. It's probably too early to determine navigability, though.
Doctor, patient, and nurse are roles played by persons in a hospital. Nurses treat patients. The treatment of a patient is prescribed by a doctor.
B. Using the previous class diagram as a T-Box model, draw an object diagram (A-Box model) modeling the following scenario:
At
C. Translate the diagram from B into Java or C++ class declarations. Your code should not allow type errors such as patients treating nurses or nurses prescribing treatments. Create a test harness for your declaration based on the object diagram in B. In other words, create the objects and links that appear in your object diagram. Be sure to print some sort of diagnostic messages to make sure that your test harness is executing correctly.
D. Create a new object diagram from the object diagram in B, modeling the following scenario
At
Recall the Types as Objects Pattern uses objects rather than classes to indicate the type of an object. Repeat #1, but this time assume Doctor, Nurse, and Patient are instances of the Role class.
A quantity is a number coupled with a unit. For example:
37 miles
3.14 Euros
42 grams
Like quantities can be added together:
3.14 Euros + 2.53
Euros = 5.67 Euros
3.14 Euros + 42 grams = ERROR
Note that we can think of the unit of a quantity as its type. This gives us another example of the Types as Objects pattern.
A. Implement and test a Quantity class.
B. Your boss suggests representing the unit of a quantity by its class. Here's a sketch of his design:
How would you explain the advantages of your Types as Objects design over this Types as Classes design?
C. Extend and test your implementation from A to allow extensible and automatic unit conversions such as:
3 inches + 1 meter = 42 inches
You may assume one unit can be converted to another unit (measuring the same phenomenon) simply by multiplying by a conversion factor. For example:
n meters = 39 * n inches
n inches = n/39 meters
Hint: to make your implementation extensible, consider storing your conversion factors in conversion tables associated with units.
A. Add the following information to your class diagram from #2:
Nurses observe patients. There are two types of observations: measurements (temperature, pulse, etc.) and categorizations (sex, blood type, etc.)
The result of a measurement is a quantity (37 degrees celsius, 70 beats/sec, etc.) The result of a categorization is a category (female, blood type A, etc.)
An observation takes place at a certain time and is an observation of a particular phenomemon (temperature, blood type, etc.)
B. Using the class diagram above as a T-Box model, draw a conforming object diagram (A-Box model) modeling the following scenario:
On June 16, 1904 at 18:00 nurse Smith observes that patient Jones' temperature is 40 degrees celsius and his blood type is AB. Later that evening, at 20:00, nurse Smith observes that patient Jones' temperature has dropped to 37 degrees celcius.