registrationsystem.model
Class Course

java.lang.Object
  extended by registrationsystem.model.Course

public class Course
extends java.lang.Object

Representation for a course


Constructor Summary
Course(java.lang.String id, int limit)
          Constructor
 
Method Summary
 void addEnrolledIn(java.lang.String studentName, EnrolledIn newEnrolledIn)
          Add a new enrollment to the course
 void addWaiting(Student student)
          Add a student to the waiting list for a course
 boolean areAnyWaiting()
          Test to see whether any students are waiting to get into the course
 EnrolledIn getEnrolledIn(java.lang.String studentName)
          Accessor for the enrollment for a specific student
 java.lang.String getId()
          Accessor for the course's id
 boolean hasRoom()
          Test to see if there is room for another student in this course.
 boolean isEnrolledIn(java.lang.String studentName)
          Test to see whether a given student is enrolled in the course
 void printReport()
          Print a report on the course - enrollments and waiting list
 void removeEnrolledIn(java.lang.String studentName)
          Remove the enrollment for a specific student
 Student removeFirstWaiting()
          Remove the first student from the waiting list when a slot opens up
 void removeWaiting(Student student)
          Remove a specific student from the waiting list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Course

public Course(java.lang.String id,
              int limit)
Constructor

Parameters:
id - the course's id
limit - its enrollment limit
Method Detail

getId

public java.lang.String getId()
Accessor for the course's id

Returns:
the course's id

addEnrolledIn

public void addEnrolledIn(java.lang.String studentName,
                          EnrolledIn newEnrolledIn)
                   throws java.lang.IllegalArgumentException
Add a new enrollment to the course

Parameters:
studentName - the name of the student being enrolled
newEnrolledIn - the new enrollment to add
Throws:
java.lang.IllegalArgumentException - if the student is already enrolled in this course

getEnrolledIn

public EnrolledIn getEnrolledIn(java.lang.String studentName)
                         throws java.lang.IllegalArgumentException
Accessor for the enrollment for a specific student

Parameters:
studentName - the student's name
Returns:
the enrollment object.
Throws:
java.lang.IllegalArgumentException - if the student is not enrolled

removeEnrolledIn

public void removeEnrolledIn(java.lang.String studentName)
                      throws java.lang.IllegalArgumentException
Remove the enrollment for a specific student

Parameters:
studentName - the student's name
Throws:
java.lang.IllegalArgumentException - if the student is not enrolled

addWaiting

public void addWaiting(Student student)
                throws java.lang.IllegalArgumentException
Add a student to the waiting list for a course

Parameters:
student - the student to add
Throws:
java.lang.IllegalArgumentException - if the student is already in the course or on the waiting list

removeFirstWaiting

public Student removeFirstWaiting()
Remove the first student from the waiting list when a slot opens up

Returns:
the student that was removed

removeWaiting

public void removeWaiting(Student student)
                   throws java.lang.IllegalArgumentException
Remove a specific student from the waiting list

Parameters:
student - the student to remove
Throws:
java.lang.IllegalArgumentException - if the student is not on the waiting list

printReport

public void printReport()
Print a report on the course - enrollments and waiting list


isEnrolledIn

public boolean isEnrolledIn(java.lang.String studentName)
Test to see whether a given student is enrolled in the course

Parameters:
studentName - the name of the student
Returns:
true if the student is enrolled

areAnyWaiting

public boolean areAnyWaiting()
Test to see whether any students are waiting to get into the course

Returns:
true iff there is at least one student on the waiting list

hasRoom

public boolean hasRoom()
Test to see if there is room for another student in this course. (There will be room if the current enrollment count is less than the limit)

Returns:
true if there is room in the course