Пример #1
0
       /*
        * Method: ReSchedule
        * Parameters: CompressedClassTime ct
        * Output: N/A
        * Created By: Scott Smoke
        * Date: 5/4/2015
        * Modified By: Scott Smoke
        * 
        * Description: This takes a breath first approach by inserting
        * an exam in the first day near the time of the start time of the compressed class time.
        * Once there are no more slots at the time of the compressed class it then moves onto checking
        * if there are any more slots avalable for each day.
        * 
        */ 
        private void ReSchedule(CompressedClassTime ct)
        {
            //checks the nearest time slots to the compressed class times start time.
            foreach (FinalExamDay fed in examWeek)
            {
                //correcting for CompressedClassTime GetClassTimeStartHour only returning a 2 digit integer
                int startTime = ct.GetClassTimeStartHour() * 100;
                int endTime = startTime + MilitaryTime(tc.GetLengthOfExams() +
                    tc.GetTimeBetweenExams());

                if (fed.HasAvailableTime(startTime, endTime))
                {
                    InsertExam(fed, ct, startTime, endTime);
                    return;
                }
                
            }
            //if there were not any start times avaialable near the start time of the compressed time.
            foreach (FinalExamDay fed in examWeek)
            {
                int startTime = tc.GetStartTime();
                int endTime = startTime + MilitaryTime(tc.GetLengthOfExams() +
                    tc.GetTimeBetweenExams());
                FindAvailableSlot(fed, ct, startTime, endTime);
            } 
        }
Пример #2
0
       /*
        * Method: Schedule
        * Parameters: CompressedClassTime ct
        * Output: N/A
        * Created By: Scott Smoke
        * Date: 5/3/2015
        * Modified By: Scott Smoke
        * 
        * Description: This takes a depth first approach and fills up
        * each day before moving onto the second. In more specific terms, it takes in
        * a compressed class time and sees if it will fit into the first exam day, nearest the start time of
        * the compressed class time, if not
        * then it sees if there are any available time slots for that day left. If there are 
        * no more exam slots for that day then it moves onto the next.
        */ 
        private void Schedule(CompressedClassTime ct)
        {
            foreach (FinalExamDay fed in examWeek)
            {
                //correcting for CompressedClassTime GetClassTimeStartHour only returning a 2 digit integer
                int startTime = ct.GetClassTimeStartHour()*100;
                int endTime = startTime + MilitaryTime( tc.GetLengthOfExams() +
                    tc.GetTimeBetweenExams());
                //cheecks the nearest slot available to compressed class start time
                if(fed.HasAvailableTime(startTime,endTime))
                {
                    InsertExam(fed, ct, startTime, endTime);
                    return;
                }
                else
                {
                    startTime = tc.GetStartTime();
                    endTime = startTime + MilitaryTime(tc.GetLengthOfExams() + 
                        tc.GetTimeBetweenExams());
                    //if not then we check for any available start times on current day.
                    while (startTime < Globals.END_OF_EXAM_DAY)
                    {
                        if (fed.HasAvailableTime(startTime, endTime))
                        {
                            InsertExam(fed, ct, startTime, endTime);
                            return;
                        }
                        startTime = startTime +
                            MilitaryTime(tc.GetLengthOfExams()
                            + tc.GetTimeBetweenExams());

                        endTime = startTime +
                            MilitaryTime(tc.GetLengthOfExams()
                               + tc.GetTimeBetweenExams());
                    }
                    
                }
            }
        }