next up previous
Next: Your job in this Up: No Title Previous: The SystemClock

   
CurrentSpeed

We discuss just two other classes in this project, because the others are similar.

First, an instance of class ClockedFrame is a thread of execution that synchronizes with the clock. Thus, within this class, you see a method run, which is a loop that at each iteration synchronizes with the clock. That is all.

Also, this class is a Frame on the monitor screen. This class is a superclass of CurrentSpeed as well as of several other classes, so an instance of CurrentSpeed is an executable thread.

Now turn to subclass CurrentSpeed. Besides some components for the Frame (two labels), there is only one variable, speed, which contains the current car speed in the simulation. The constructor just constructs the Frame, shows it, and returns; there is nothing special about it.

Methods readValue and setValue can be called to reference and set the current speed. Classes DesiredSpeed and RoadGrade are nearly identical. Class Accelerator is only slightly more complicated, with two additional methods for turning the accelerator ``on'' and ``off''.



Claire Cardie
1998-11-11