CS 112b
Spring 2002
Ileana Streinu

Homework 4

Thursday Feb. 21, 2001
Due Wednesday 02/27/2001 by midnight


Outline

UNDER CONSTRUCTION.
This homework is your first application of the object-oriented programming approach. All the code must be written using classes and the object-oriented methodology we learned this week.

The problem

Assume that you have been hired to write a program for monitoring the usage of the swimming pools of the Five Colleges: Smith, MtHolyoke, Hampshire, Amherst and UMass. For each swimming pool, you assume that at most 20 swimmers can use it at a time, and that there is no information whatsoever about what lanes are used (in other words, I want you to use some struct's which you will define, and which are simpler than the ones we discussed in class today).

You want to collect various information about the swimmers using the pool at any time: age, level, sex, type (student/faculty/staff or other), name. The information is updated whenever a swimmer enters or leaves the swimming pool. In "real life", you can imagine that some id card is automatically scanned, but for now your user interface will get the data from the keyboard, in the following format:

swimmer_name sex type level age

where:
The program also has functions to output useful information about each one of the five swimming pools:

The user interface

The main program uses a menu-based interface for the various functions of the system. The options are: For options 1 and 2, the user is first prompted to enter a number for the school (0 for Smith, 1 for MtHolyoke, 2 for Hampshire, 3 for Amherst and 4 for UMass), then either enters the data in the format described above, or chooses what output function to perform.

If the user chooses to output information, then there will be a menu of 4 options:

The program

The program is inspired but does not use EXACTLY the struct's defined in class today (see old struct definitions here). In particular, notice that there is no information about lanes in the swimming pool structure, so you will have to redesign the struct for swimming_pool to store only information about the swimmers currently using the pool (at most 20).

For sorting, you should use InsertionSort with templates (but there is just a little subtlety about it, which will be explained and worked on in class on Tuesday). So you can work on all the other functions except those involving sorting by Tuesday. I suggest that you work out the functionality of the whole system before the Tuesday class, including an empty sort function (which does nothing). Then after class on Tuesday you will just substitute the appropriate templated sorting function.

You should use appropriate functions whenever the logic of the program dictates it.

Remember that the quality of your programming style is based on the appropriate use of variables, functions, define's, switch statements, arrays and struct's, as well as on readability, commenting, well-testing and completeness (all files submitted).

So revise these criteria before submitting your program.

Submit using submit Hw4.
Ileana Streinu