IUP Computer Science
CO 310 Spring 1997

Project 5
(Due   14 April 1997)

In this project you are to write a program that simulates a simple student registration for classes. You are required to use one or more linked list objects, based on the class definition and implementation in the file CLIST.H, which is contained in 310LIB:, O:\JLW\310 and L:\JLW\310. The data for the simulation is in the file REGISTER.DAT (it contains all the registration actions); the data file can be found in the same three directories.

REGISTER.DAT is arranged as follows. On the first line is a number indicating how many course pairs are on the next line. On the second line is a list of pairs consisting of a number showing how many seats are available and a course number; the example below shows three courses with 5 seats, 7 seats, and 4 seats. The courses appear in alphabetical order on the second line.

3
5 AN110  7 CO310  4 EN121

This is followed by lines on which there is one action per line. Each action is indicated by the single lowercase letter: 'a' indicates a student is adding a course, 'd' indicates a student is dropping a course, 's' indicates a status request to see how many seats are available in all courses, 'c' indicates a student wants a list of the total credits (each course is 3 credits) and courses s/he is registered for, 'l' is not used but must be recognized and ignored, and 'q' indicates to quit the simulation - the program should show a list of credits and courses for each student. Following are several action lines - note that each student name is a single word. The first indicates Mary is adding CO310; the second requests a seat status; the third displays Mary's schedule; the fourth should be read and ignored; the fifth indicates Lee is dropping AN110; and the last ends the simulation.

a Mary CO310
s
c Mary
l
d Lee AN110
q

Your program must use a linked list object to record each student's schedule. Each student occupies a node in the list; the list must be kept in alphabetical order; each student's node must point to a linked list object that holds a node for each course in which a student is registered - the courses must also me kept in alphabetical order.

The class for the linked list objects is named Clist; Clist objects are circular linked lists with header nodes Each node on such a list has the following fields; all fields are private:

char        name[10];      // To hold a short string
int         count;         // To hold an integer
ClistNode   *Next;         // Pointer to next node in list
Clist       *Associate;    // Pointer to an associated linked list
As actions are taken (from the REGISTER.DAT file), a multi-list is formed that looks something like this.

Your program should search, add to, and delete from this list as it performs the various actions. I would recommend that you keep the courses and seats in another Clist object - this should make performing the actions easier.

For each 'c' and 's' action and for errors, your program needs to generate output. Your program should write all output related to the actions to a file called A:\OUTCOME.DAT; don't write to the screen. Hand in a printout of your program, a printout of OUTCOME.DAT, nd a disk containing your program in a file named you-P5.CPP where you is your initials.


For extra credit, make the 'l' command work. When the 'l' command is read, have your program display a class list for all courses.