To start a registration session, first drag a copy of the complete
folder CS105 (Tucker) -> Registration to your desktop and and close
the CS105 (Tucker) window. Now open the copied Registration
folder on your desktop and double-click on the file Registration.pbproj
that is inside. To obtain the screen shown below, follow these
steps:
This frame provides all the elements needed for a primitive on-line registration system. When it is complete, it will enable a student to sign in, show all available courses in the "Course list" window, enroll in up to four courses, and display her four course selections. Reading each line in the above "Course list", we see a course number (e.g., ANTH101), a current enrollment (e.g., 50), an enrollment capacity (e.g., 50) ,and a waiting list (e.g., 97). On the right, the course title and instructor's name also appear.
Now select the menu item "Show all students" and you will see a list of students and id numbers for everyone in our class.
Altogether, over 100 courses are available for registration, and only 23 students have not yet registered (you guessed it, our class). Some of these courses are already full to capacity, as indicated in the above display. Any student in our class may register for any course that is not full. The system should update the totals for each course that any student adds, keeping track of how many courses each student has already selected (and ensuring that that number does not exceed 4).
To register for classes, you must first "sign in" to the system by selecting "Next Student" in the menu at the top of the frame. The system will ask for an ID number (like A6001) in the text area labeled "Echo area", and you will type it in the text field labeled "typing area." The system should then check to see if the ID number entered matches that of a class member.
If not, you will get the message "Invalid ID number: try again." If the ID number matches, you may then proceed to select courses (one at a time) by choosing the menu option "Add a course" and then typing the number of the course you want in the typing area.
Later in the session, you can change your mind by selecting "Delete a course" and entering the number of a previously-selected course that you want to delete from your list of selections.
The system should keep track of the courses that a student has already selected, and ensure that a student doesn't try to select the same course twice. To view all the courses you have already enrolled in, you can select the menu item "Show my courses."
The display above gives the message "null has made 0 selections," indicating
that no-one has yet signed in or added any courses (see below for more discussion
of this event).
Once a student has completed his/her registration session, any other student in this group can register for courses by initiating a similar sequence of events -- first entering their student ID number and then selecting 1-4 courses to add to his/her course list. A redisplay of the entire course list, updated with new enrollments for all students in this session, may also be obtained by reselecting the "Show all courses" menu item at any time.
The session continues for as many students in this group who wish to register. Once the session is ended, however, the results of the session and all enrollment numbers are lost. After all, CAMP BOBO is only a mythical college!
// State variables used by the AppletFive arrays hold the information for the courses, and the variable ncourses holds the total number of courses being offered. These arrays are "parallel" arrays, in the sense that any particular index value, say i, references a course number (course_no[i]), its name (course_name[i]), its enrollment capacity (capacity[i]), its current enrollment (enrollment[i]), and the size of its waiting list (waitlist[i]). For example, if i=3, these five array references have the values "ANTH224", "POP CULTURE CARIBBEAN N. Stoltzoff", 50, 31, and 1, respectively.
Button start_button;
Choice user_choices;
TextArea course_list;
TextArea echo_area;
TextField user_typing;
String current_choice;
// arrays of course numbers, course names, capacities, enrollments, and waiting lists
String [] course_no = new String [200];
String [] course_name = new String [200];
int [] capacity = new int [200],
enrollment = new int [200],
waitlist = new int [200];
int ncourses; // total number of courses available
// arrays of student names and id numbers
String [] student_names = new String [30];
String [] student_ids = new String [30];
int nstudents; // total number of students who can register
// information for a student about to register
String name, id; // name and id number of current student
int nselected ; // the number of courses selected (up to 4)
String [] selections = new String[4]; // numbers of courses selected
The names of individual students and their ID numbers are kept in two other parallel arrays (student_names and student_ids), and the variable nstudents tells how many students are in these arrays (23 for our class). Information for the student who is currently registering for courses is given by the variables name, id, nselected (number of courses selected), and the array selections holds the individual course numbers that were selected by that student.
The handler itemStateChanged starts the interaction by responding to a particular user selection in the menu user_choices.
The handler actionPerformed captures information typed by a registering student in the user_typing area -- either their ID number (if they are signing in) or a course number to be added or deleted.
Each of these different registration events is assisted by a specific method designed to do the hard work.
The method processIDNumber should receive a String s, look it
up in the array of student ID numbers, and (if found) initialize the variables
name and nselected to 0. If the ID number typed is
not found in this array, an appropriate message should be displayed in the
echo area. Notice also that this method should return true or false,
depending on whether or not a valid student ID number was entered. You
must complete the details of this method.
The method processAddACourse should look up the course in the
course_no array and, if it is there, check to see if:
If all these are true, the enrollment for that course should be increased by 1, the course should be added to the student's list of courses selections, and the number of courses nselected for that student should be increased by 1. Whether or not this is true, an appropriate message should appear in the echo_area to indicate whether or not the course was successfully added and the method should return true or false accordingly. You must complete the details of this method.
A similar set of steps is required for the method processDeleteACourse , which is also not complete. This method should look up the course in the array selections, remove it from that array, decrease by 1 the enrollment for that course, and subtract 1 from the variable nselected, displaying an appropriate message in the echo_area and returning true or false accordingly. You must complete the details of this method.
Finally, the method showStudentSelections will display in the echo_area the student's name and a list of the courses she has selected. It is called when the menu selection "Show my courses" is made.
Your task in this lab is to complete the details of the three methods processIDNumber, processAddACourse, and processDeleteACourse so that the entire registration system works correctly for each student in our class. When finished, turn in a hard copy of your Registration<yourname>.java file and leave an electronic copy of that file in the Drop Box.