コード例 #1
0
ファイル: Course.cs プロジェクト: AMrE4U/ScheduleGenerator
        public bool IsConflict(Section lecture, Section lab, bool includeOnlineAppt)
        {
            if (lecture.days == "NULL" || lab.days == "NULL")
            {
                if (includeOnlineAppt)
                    return false;
                // if they don't want online classes, NULL for days is treated like a conflict
                else
                    return true;
            }
            else
            {
                if (lecture.days.Intersect(lab.days).Count() > 0)
                {
                    if (lecture.startTime >= lab.startTime && lecture.startTime <= lab.endTime)
                    {
                        return true;
                    }
                    else if (lecture.endTime >= lab.startTime && lecture.endTime <= lab.endTime)
                    {
                        return true;
                    }
                    else if (lecture.startTime <= lab.startTime && lecture.endTime >= lab.endTime)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
コード例 #2
0
ファイル: Schedule.cs プロジェクト: AMrE4U/ScheduleGenerator
        public bool IsConflict(Section sectionToCheck, List<Section> currSched)
        {
            if (sectionToCheck.days == "NULL")
            {
                return false;
            }
            else
            {
                foreach (Section currSection in currSched)
                {
                    if (sectionToCheck.days.Intersect(currSection.days).Count() > 0)
                    {
                        if (sectionToCheck.startTime >= currSection.startTime && sectionToCheck.startTime <= currSection.endTime)
                        {
                            return true;
                        }
                        else if (sectionToCheck.endTime >= currSection.startTime && sectionToCheck.endTime <= currSection.endTime)
                        {
                            return true;
                        }
                        // if a section surrounds another section (lab from 7:30 to 11:20 as sectiontocheck and lec from 10 to 10:50 as currsection)
                        else if (sectionToCheck.startTime <= currSection.startTime && sectionToCheck.endTime >= currSection.endTime)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }