4.1 Requirements of the time and position classes and methods

Our eventual goal in this book is to develop a sample application based on an airport theme. The sample application handles the scheduling of aircraft that are arriving into and departing from an airport. For more information, see Chapter 15, Design of the Airport Application.

We know that, for our airport application, we need to represent time. There are several ways to represent time. We could say that an event happened 2 hours ago (a time offset). We could say that an event happened at 21:30 (a time of day). We must represent both kinds of time in our time library, and we must provide a way to print representations of both. In this chapter, we define a class named <time-of-day>, and we define a method that prints a representation of <time-of-day>. In Chapter 5, Class Inheritance, we define the <time-offset> class, and a method that prints a representation of <time-offset>.

The airport application also requires us to represent physical objects (such as aircraft), and the positions (locations) of physical objects. In Chapter 7, Modularity, we define classes that represent physical objects and positions.

Eventually, we need to be able to add times, to compare times for similarity, and to determine which of two times is greater than the other. We implement those operations in Chapter 6, Multimethods.

We package the result of all our work into a complete and working library, in Chapter 8, A Simple Library. Later, we refine this library to achieve greater modularity and extensibility. The final result is given in Chapter 14, Four Complete Libraries.