public bool HasConfilct(ScheduleSlot otherScheduleSlot) { foreach (ScheduleSlot scheduleSlot in schedule) { if (scheduleSlot.HasConflict(otherScheduleSlot)) { return true; } } return false; }
public static List<Schedule> GenerateAllPossibleSchedule(Course course) { string courseID = course.courseID; string semester = course.semester; List<Section> lectureList = course.getSectionListByType(SectionType.Lecture); List<Section> tutorialList = course.getSectionListByType(SectionType.Tutorial); List<Section> practicalList = course.getSectionListByType(SectionType.Practical); List<Schedule> lectureListTemp = new List<Schedule>(); List<Schedule> tutorialListTemp = new List<Schedule>(); List<Schedule> practicalListTemp = new List<Schedule>(); List<Schedule> scheduleList = new List<Schedule>(); foreach (Section lectureSection in lectureList) { Schedule schedule = new Schedule(); Schedule mergedSchedule = schedule.AddScheduleSlot(new ScheduleSlot(courseID, semester, lectureSection)); lectureListTemp.Add(mergedSchedule); } if (lectureListTemp.Count != 0) { scheduleList = lectureListTemp; } else { if (tutorialListTemp.Count != 0) { foreach (Section tutorialSection in tutorialList) { Schedule schedule = new Schedule(); Schedule mergedSchedule = schedule.AddScheduleSlot(new ScheduleSlot(courseID, semester, tutorialSection)); tutorialListTemp.Add(mergedSchedule); } } } foreach (Section tutorialSection in tutorialList) { foreach (Schedule schedule in lectureListTemp) { ScheduleSlot tutorialScheduleSlot = new ScheduleSlot(courseID, semester, tutorialSection); if (!schedule.HasConfilct(tutorialScheduleSlot)) { Schedule mergedSchedule = schedule.AddScheduleSlot(tutorialScheduleSlot); tutorialListTemp.Add(mergedSchedule); } } } if (tutorialListTemp.Count != 0) { scheduleList = tutorialListTemp; } else { tutorialListTemp = scheduleList; } if (lectureListTemp.Count == 0 && tutorialListTemp.Count == 0 && practicalListTemp.Count != 0) { foreach (Section practicalSection in practicalList) { Schedule schedule = new Schedule(); Schedule mergedSchedule = schedule.AddScheduleSlot(new ScheduleSlot(courseID, semester, practicalSection)); practicalListTemp.Add(mergedSchedule); } } foreach (Section practicalSection in practicalList) { foreach (Schedule schedule in tutorialListTemp) { ScheduleSlot practicalScheduleSlot = new ScheduleSlot(courseID, semester, practicalSection); if (!schedule.HasConfilct(practicalScheduleSlot)) { Schedule mergedSchedule = schedule.AddScheduleSlot(practicalScheduleSlot); practicalListTemp.Add(mergedSchedule); } } } if (practicalListTemp.Count != 0) { scheduleList = practicalListTemp; } return scheduleList; }
public bool HasConflict(ScheduleSlot otherScheduleSlot) { return section.HasConflict(otherScheduleSlot.section); }
public Schedule AddScheduleSlot(ScheduleSlot scheduleSlot) { List<ScheduleSlot> newSchdule = this.schedule.Select(s => s).ToList(); newSchdule.Add(scheduleSlot); return new Schedule(newSchdule); }