コード例 #1
0
        public bool HasConfilct(ScheduleSlot otherScheduleSlot)
        {
            foreach (ScheduleSlot scheduleSlot in schedule)
            {
                if (scheduleSlot.HasConflict(otherScheduleSlot))
                {
                    return true;
                }
            }

            return false;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 public bool HasConflict(ScheduleSlot otherScheduleSlot)
 {
     return section.HasConflict(otherScheduleSlot.section);
 }
コード例 #4
0
 public Schedule AddScheduleSlot(ScheduleSlot scheduleSlot)
 {
     List<ScheduleSlot> newSchdule = this.schedule.Select(s => s).ToList();
     newSchdule.Add(scheduleSlot);
     return new Schedule(newSchdule);
 }