scheduler.generate
Class FindCourse

java.lang.Object
  extended by scheduler.generate.FindCourse

public class FindCourse
extends java.lang.Object

This class contains methods for selecting the most ideal course for a particular instructor to teach. This method was not included in Generate.java b/c there were multiple persons working on various aspects of the class. So, to enable each person to do his/her work w/o fear of conflicts, each important schedule of scheduling functiontionality was broken into its own, individual class.

Author:
Eric Liebowitz

Constructor Summary
FindCourse()
           
 
Method Summary
private static void checkPre(java.util.LinkedList cdb, java.util.LinkedList idb, Instructor i)
          Checks the preconditions for "findIdealCourse(...)" and throws appropriate exceptions.
protected static Course findIdealCourse(java.util.LinkedList<Course> cdb, java.util.LinkedList<Instructor> idb, Instructor i)
          Finds the most suitable course for a given instructor to teach.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindCourse

public FindCourse()
Method Detail

findIdealCourse

protected static Course findIdealCourse(java.util.LinkedList<Course> cdb,
                                        java.util.LinkedList<Instructor> idb,
                                        Instructor i)
                                 throws NullCourseDatabaseException,
                                        EmptyCourseDatabaseException,
                                        NullInstructorException,
                                        InstructorNotInDatabaseException,
                                        InstructorWTUMaxedException,
                                        InstructorCanTeachNothingException
Finds the most suitable course for a given instructor to teach.

Parameters:
cdb - Database of courses
idb - Database of instructors
i - The instructor to select for
Returns:
The most ideal course to give this instructor. If this instructor cannot be assigned any more classes (i.e. maxed wtu's; no classes) available), null.

 // **Pre and Post conditions** //
 
 Pre:

    //The course database cannot be null
    db.coursedb != null

       &&

    //The course database must have at least one entry
    db.courseDB.getSize() > 0


       &&

    //Instructor cannot be null
    instructor != null

       &&

    //Instructor must be in the instructor database
    db.instructorDB.isValidInstructor(instructor)

       &&

    //Instructor "i" has a Treatment entry in the treatment hash
    Generate.treatment.get(i) != null

 Post:

    //The class returned must be one the instructor is "qualified" to teach
    instructor.getPref(return) > 0

       &&

    //The returned class must be in the course database
    cdb.contains(return)

       &&

    //The returned class must not push the instructor over his max WTU 
    //count
    treatment.get(i).wtu + return.getWTU() <=
        instructor.getMaxWTU()
 
Throws:
NullCourseDatabaseException
EmptyCourseDatabaseException
NullInstructorException
InstructorNotInDatabaseException
InstructorWTUMaxedException
InstructorCanTeachNothingException

checkPre

private static void checkPre(java.util.LinkedList cdb,
                             java.util.LinkedList idb,
                             Instructor i)
                      throws NullCourseDatabaseException,
                             EmptyCourseDatabaseException,
                             NullInstructorException,
                             InstructorNotInDatabaseException,
                             InstructorWTUMaxedException,
                             InstructorCanTeachNothingException
Checks the preconditions for "findIdealCourse(...)" and throws appropriate exceptions. NOTE: If there is no entry for a given instructor in the Treatment hash, an empty entry will be immediately created, so as to avoid those nasty NullPointerException's.

Parameters:
cdb - The course database
idb - The instructor database
i - The instructor
Throws:
NullCourseDatabaseException
EmptyCourseDatabaseException
NullInstructorException
InstructorNotInDatabaseException
InstructorWTUMaxedException
InstructorCanTeachNothingException