©2005 Felleisen, Proulx, et. al.

Classes with Containment


+-----------------------------+            
| WeatherRecord               |            
+-----------------------------+            
| Date d                      |-----------------+
| TemperatureRange today      |--+              |
| TemperatureRange normal     |--+              |
| TemperatureRange record     |--+              |
| double precipitation        |  |              |
+-----------------------------+  |              |
                                 v              v
              +---------------------+   +------------+
              | TemperatureRange    |   | Date       |
              +---------------------+   +------------+
              | int high            |   | int day    |
              | int low             |   | int month  |
              +---------------------+   | int year   |
                                        +------------+

Figure 2: A class diagram for weather records

1.4  Problem (3.1.2)

Take a look at the data definition in figure 2. Translate it into a collection of classes. Also create examples of weather record information and translate them into instances of the matching class.

1.5  Problem (3.1.3)

Revise the data representation for the book store assistant in problem 1.2 so that the program keeps track of an author's year of birth and the author's name. Modify the class diagram, the class definition, and the examples.