The George Washington University
School of Engineering and Applied Science
Department of Electrical Engineering and Computer Science
CSci 51 -- Spring 1999 -- Project #7
Due Date: start of class, Thursday, April 8, 1999

This project builds on the work done in Project 6. In this project you will change the speed monitor so that it operates in terms of clock times instead of the simulated time we used in Project 6. The changes are very straightforward.

First,modify the speed monitor package so that ArrivalTimes is now a subtype of Duration, Ada's type that represents elapsed time. The new spec will look like

PACKAGE Speed_Monitor IS
 
  TYPE SpeedClasses IS (Class1, Class2, Class3, Class4, Class5);
  SUBTYPE Speeds IS Natural RANGE 0..130;
  SUBTYPE ArrivalTimes IS Duration RANGE 1.0..60.0;
  
  FUNCTION Classify (Speed: Speeds) RETURN SpeedClasses;
  -- Pre: Speed is defined
  -- Post: Returns the class of the given speed
 
  PROCEDURE DeliverSpeed (Speed: OUT Speeds; Time: OUT ArrivalTimes);
  -- Pre: None
  -- Post: Delivers a random speed in the range 40..80
  --       and a random elapsed time
 
END Speed_Monitor;
You'll have to modify the procedure DeliverSpeed so that the integer value delivered by the random number generator is converted to the ArrivalTimes subtype.

Second, change your main program so that the time is reported as an actual time of day rather than an elapsed integer value. Declare your elapsed time variable as Ada.Calendar.Time. Note that Ada.Calendar (p.485) provides a "+" operation to add a Duration value to a Time one.

Program 7.3 shows how to display a value of Ada.Calendar.Time. For each arriving car, classify its speed, and display the elapsed time, speed, and speed class, like this:

Time 12:40:17, Speed 57, Class 3

Finally, at the end of the run, display the total number of cars in each speed category.