University of Toronto Department of Computer Science CSC108H, Summer 1998
Assignment 3: Triathlon Information
Due: at the beginning of your tutorial Wednesday, Jul 15.

The Problem

A triathlon is a sport involving three separate events: swimming, bicycling and running, run in succession with continuous running time. The business of running triathlons has been computerized. The registration process involves human data entry. Our model begins when a person registers. At this point a competitor's category is determined and a unique triathlete number is assigned. We are also interested in modeling, collecting timing information during the competition. During the race, the running time for each competitor is entered as they complete each event. Timing information and the order of finishers in each event is updated as times are entered. After the race is officially over, the results are printed.

In recent triathlon's, each competitor is given a computer chip to carry during the race, that contains an assigned triathlete number. As a competitor passes a checkpoint, the chip reports this number to a checkpoint sensor that sends the sensor's event, assigned triathlete number, and the current running time to a central computer which calculates the individual's event time. There are checkpoints at the end of the swim, the bike and the run which is also the finish line. Sometimes triathlons end with the swim. In particular, you cannot assume that swim times are entered at the computer in the order that they should finish the swim.

The Program

The program begins by reading in ``MaxTriathlonSize'' literally followed by a number which will be the maximum number of competitors allowed.

Your program must contain at least five classes.

Your Task

Write a Java program that reads the commands and associated data listed below and processes the data appropriately.

For each competitor, event times are entered in the order of the events; swim, bike, run. It is possible that a competitor may have a faster time in some events that other competitors yet have their times entered later simply because another competitor could be faster in an earlier event. If a competitor doesn't finish an event then you can't insert them into an event ordering. Current time is entered in seconds, the output event and final times should be of the form: <hours>:<minutes>:<seconds>.

If input is invalid then you should handle it in a reasonable way.

You are required to do minimal error checking and handling only for this assignment. However, you may earn a maximum of two bonus marks for good error checking and handling.

(The maximum grade for the assignment is 10. The bonus marks may be used to offset marks you lose for other reasons.)

Required test input file
Sample output on this input file

Hints and Suggestions

  1. This program will be larger and more complex than your first two. Start this assignment early.
  2. Look at the Roll_Call example on pp. 223-224 of your textbook. The relationship between the classes there and the use of an array of objects of class Member is similar to what you must implement for this assignment. The Member class is close to the single category class described above. Also look at Assignment 3 from the Spring term.
  3. Think about the structure of your program carefully before you start writing it. For example, what data should each class contain and what services should it provide to its clients? Start by drawing an object diagram of the relationships between the classes. If you get the structure right, the program will be much easier to write.
  4. Get the essential parts working first before you try to complete the whole program. For example, be sure that your triathlete class works correctly by testing it thoroughly on its own before you include it in your full program.
  5. Start small: Begin with a simplified version of the assignment. For example, you might first write a simplified version of the program in which the triathlete class contains only the name, number and event time of each triathlete and implement only the MaxTriathlonSize, Register, and the ReportRegistered command. After this simplified program is working, add the other classes and commands. Finally, add error detection and handling. (See the section on Bonus Marks above.) Note that, if you follow this strategy and you don't complete all of the assignment, you will still have something that works to hand in.
  6. If you do attempt to detect errors and handle them appropriately, you might find it useful to read pages 488 to 492 or your textbook first. This section discusses Java's exception handling facilities.

Testing Your Program

What To Hand In

Please use the ``Print Java Assignment'' program.

About this document ...

Wed Jun 24 15:40:04 EDT 1998


Craig MacDonald
Wed Jun 24 15:40:08 EDT 1998