//## Kick ass README. Only recommendation I could make would be to put //## headers for every section. And even then, that's not too important //## because the stuff is well written and organized. //Name: XXXXXXXXXXXXXXXXX //CS70, Fall 1999 //Assignment #3 ------------------------------------------------------------------------------- This program implements and automates an interactive course database, created for use by a college registrar's office. It stores all pertinent information regarding the students and courses at the school, and allows the registrar to keep track of changes to either. ------------------------------------------------------------------------------- This program will display a menu of choices for the registrar when run. At the prompt, the registrar simply needs to type one of the available commands, then supply whatever information he/she is prompted to input to the command line. The interface is relatively intuitive, and the menu choices are all explained to the user. The user display a complete listing of the students and their schedules, as well as a complete listing of the courses and their rosters directly from the menu. ------------------------------------------------------------------------------- The program can take text input of essentially any size, as the length of the string is limited by the boundaries of the "int" type. The database will hold no more courses and students than the limits set in assign_03.cc but these values could easily be modified. _______________________________________________________________________________ Provided that the user gives reasonable input whenever prompted, there are no known bugs in this program. It is possible to "break" the program by giving it alphanumeric characters when it expects an integer for the course number, but this is due to a lack of error-checking in the assign_03.cc file which was to be left unchanged. ------------------------------------------------------------------------------- The algorithm in this program works as follows: - A new database is created to hold the student and course listings. - The user chooses from a menu of options. The input is read in and parsed by the readString() function (explained below) into individual words. These are passed to the interact() function in assign_03.cc, which runs its method corresponding to the user's choice. "quit" will return the user to the command line prompt. "help" will redisplay the menu by calling printCommandList(cerr). "student" will prompt the user for the student's first name, last name, and hair color. It will then call the newStudent function from registrar.cc to add the new student to the database. The database uses the fillInInfo() function from the Student class to store the user-defined values, creating a new string to hold the student's full name. "course" will prompt the user for the course's department and number, as well as the days it meets, the meeting time, and the maximum enrollment. It then combines the meeting days and time into one string and calls the fillInInfo() function from the Course class in a procedure analogous to that for "student" "enroll" will add a student to a course's roster, and that course to the student's schedule. This is done by first prompting for the student's name and the course to be added. Provided that the student can add the class, assign_03.cc then calls the addCourseToSchedule() from the Student class. It could also call addStudent() from course with the same effect, as each function will call the other to complete the enrollment process. Infinite recursion is avoided by having each of the two functions check to make sure they haven't already added the course to the student's schedule or the student to the course roster, respectively. The course roster is kept alphabetized by finding the enrollee's place in the roster, shifting everyone whose name is after the enrollee's one spot down in the roster, then inserting the enrollee. "drop" will remove a student from a course's roster and the course from the student's schedule, in a procedure analogous to "enroll" above. The course roster will be kept packed (i.e. there will be no pointers to NULL in the roster). Once again, the program could call either removeStudent() from the Course class or removeCourseFromSchedule() from Student with the same result either way as they will call each other. "hair" will change the color value for the student's hair stored in the database.will prompt for the student's name, make sure the student is in the database, then prompt for that student's new hair color. It calls the changeHairColor() method from the Student class to perform the change. "time" will change the stored value for a course's meeting time. It will prompt the user for the course whose meeting time they wish to change, then for the new meeting days and time. It will then call changeMeetingTime() from Course to set the new time. "show students" will scroll a display of all the students in the college, listing their names, hair colors, and schedules. It does this by using the print() function defined in the Student class to display each student in an output stream. The Student->print() function will then call the Course->showName() function to list the courses the student is taking. "show courses" will scroll a display of all the courses in the college, listing their names and meeting times, then calling Student->showName() for every student in the class to display the roster. - The list of options is not displayed again unless the user enters "help", but instead the program simply displays "Your command?" prompting the user for more input. The readString() function works as follows: readString takes input in the form of a stream of characters. It will separate this stream into "words" (strings of characters not containing any whitespace) and return them. While the program can be modified to return its output in essentially any format, for our purposes it is most useful to have each word in double quotes, followed by a carriage return. The algorithm in readString is relatively simple. It takes an input stream of characters and parses it into words. If readString() reaches the end of the input, then it will stop trying to get new characters. The algorithm in readString() works as follows: -As long as there are input characters, -any whitespace it sees will be ignored, then -the next word will be placed into an array, then -the array (word) will be terminated with a null byte, then returned -if the file contains only whitespace, readString() will return NULL and the program will know it has reached the end of the file The functions of the individual lines of code are explained in comments in the readstring.cc file. If the array in which the word is being stored runs out of space to hold characters, then it will be sent to the expandArray() function to increase it. The program keeps track of the size of the array, as well as storing a value by which the array size will be incremented (both of which can be easily changed by the user). The expandArray() function will increment the size and return an array containing all of the data of the array passed to it. ------------------------------------------------------------------------------- The program is organized into four classes and one driver function. The driver function is contained in assign_03.cc, it contains the code that tells the program how to interact with the user. It will display the menu, call readString() (contained in readstring.cc) to get the user's choice, then make the appropriate function call to perform the requested action. The program has three data types: the registrar database, the student, and the course. The database type contains arrays of pointers to the other two classes and uses these arrays to store the university's information. In its current configuration, the registrar class is set to contain up to 128 students and up to 20 courses. The student and course classes are used to implement the functions required of a single student or course, respectively. They contain functions to manipulate the attributes of a single element, whereas the registrar class manipulates multiple. ------------------------------------------------------------------------------- The program consists of 10 files: makefile : the makefile for the program assign_03.cc : implements the part of the program visible to the user readstring.cc and readstring.hh : these perform input parsing registrar.cc and registrar.hh : implement the registrar's database student.cc and student.hh : implement a single student course.cc and course.hh : implement a single course -------------------------------------------------------------------------------