/* * 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); } }
/* * Method: FinaAvailableSlot * Parameters: FinalExamDay fed, CompressedClassTime ct, * int startTime, int endTime * Output: N/A * Created By: Scott Smoke * Date: 5/4/2015 * Modified By: Scott Smoke * * Description: This method finds an available time slot * and inserts the exam into it. * */ private void FindAvailableSlot(FinalExamDay fed, CompressedClassTime ct, int startTime, int endTime) { 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()); } }
/* * 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()); } } } }
/* * Method: InsertExam * Parameters: FinalExamDay fed, CompressedClassTime ct, * int startTime, int endTime * Output: N/A * Created By: Scott Smoke * Date: 5/3/2015 * Modified By: Scott Smoke * * Description: This inserts an exam into the specified * exam day with the specified start and end times.Notes this adds the * break time to the length of the exam. * */ private void InsertExam(FinalExamDay fed, CompressedClassTime ct, int startTime, int endTime) { FinalExam fe = new FinalExam(ct); // Debug.WriteLine("Class start hour " + ct.GetClassTimeStartHour() * 100); fe.SetStartTime(startTime); fe.SetEndTime(endTime); fed.InsertExam(fe); //debugging info //Debug.WriteLine("Day: " + fed.GetDay().ToString() + " " // + fed.GetNumberOfExams()); }