In this lab you will write a program to register students for courses. Your
program will include classes for courses, the schedule of classes, student
schedules, and times.
Course Class
Each Course object represents one course that is being offered. If there are
multiple sections of a given course, then there will be a Course object for each
section. To simplify things, we will assume that each course meets only once a
week. The fields of the Course class are:
- name (String)
- number (String)
- number of credits (int)
- section number (int)
- department offering the course (String)
- day of the week that the Course meets (String)
- start time of the class (Time)
- end time of the class (Time)
- number of students registered (int)
- maximum number of students allowed (int)
The methods of the Course class are:
- default constructor (does nothing)
- constructor to initialize all fields (pass Strings, ints, and Times as the
parameters)
- printAll (print out all the Course information in a nice format, also print
whether the course is open or closed)
- print (using a nice format, print out the name, number, section,
credits, date, start time, and end time)
- addStudent (add a student to the course if there is room, and return true
if added, false if course was already full)
- removeStudent (if there is at least one student registered, remove one and
return true, otherwise return false)
- some other small methods will probably be needed
ClassSchedule Class
A ClassSchedule object holds the schedule of classes for a single semester
-- this is the list of all classes that are being offered. The fields of the
ClassSchedule class are:
- semester (String -- example: "Spring 2000" or "Summer
2000")
- list of courses being offered (Vector)
The methods of the ClassSchedule class are:
- default constructor (set semester to "Spring 2000" and initialize
the list of courses to empty)
- constructor with one String parm (set semester to the parm and initialize
the list of courses to empty)
- add (parm is a Course object; add a Course to the schedule -- if the course
and section isn't in the schedule, add it and return true; otherwise return
false)
- print (print all Courses in the schedule)
- listByName (parm is a String for the course name; print all Courses in the
schedule which match the course name given in the parm)
- listByDept (parm is a String for the department name; print all Courses in
the schedule which are offered by the department given in the parm)
- getCourse (parms are course name and section number; return the Course
object in the schedule which matches the given name and section number)
StudentSchedule Class
A StudentSchedule object holds the schedule of a particular student. There
will be one StudentSchedule object for each student that is registering for
courses.The fields of the StudentSchedule class are:
- student name (String)
- student number (String)
- number of credits for the current semester (int)
- list of Courses on the student's schedule (Vector)
The methods of the StudentSchedule class are:
- default constructor (initialize the credits to 0 and the list of courses to
empty)
- constructor with parms for the student name and number (initialize the name
and number from the parms, initialize the credits to 0 and the list of courses
to empty)
- addCourse (parm is the Course to add; if there is room in the course, then
add the student to the Course, add the Course to the student's schedule, and
return true; otherwise return false)
- dropCourse (parm is the name of the Course; if the student is registered
for the Course, then remove the student from the Course, remove the Course from
the student's schedule, and return true; otherwise return false)
- print (print the student's schedule, use the print method of Course)
Time Class
You will need a Time class to hold and print the start and end times of
Courses. Remember that when we are talking about classes, we work with only
hours and minutes. The fields of the Time class are:
- hours, minutes, and seconds (each is an int)
- AM/PM flag (you can represent this however you want)
The methods of the Time class are:
- default constructor (initialize to some default time)
- constructor with parms for all the fields (initialize the Time to the given
values)
- toString (return a String for the Time in the format hh:mm:ss AM or PM)
- toStringNoSecs (return a String for the Time in the
format hh:mm AM or PM)