Beispiel #1
0
        private bool isOverlap(Section a, Section b)
        {
            string aStartHour = a.StartTime.ToString().Split(':')[0];
            string aStartMinute = a.StartTime.ToString().Split(':')[1];
            string aEndHour = a.EndTime.ToString().Split(':')[0];
            string aEndMinute = a.EndTime.ToString().Split(':')[1];

            string bStartHour = b.StartTime.ToString().Split(':')[0];
            string bStartMinute = b.StartTime.ToString().Split(':')[1];
            string bEndHour = b.EndTime.ToString().Split(':')[0];
            string bEndMinute = b.EndTime.ToString().Split(':')[1];

            int aStart = Convert.ToInt32(aStartHour + aStartMinute);
            int bStart = Convert.ToInt32(bStartHour + bStartMinute);
            int aEnd = Convert.ToInt32(aEndHour + aEndMinute);
            int bEnd = Convert.ToInt32(bEndHour + bEndMinute);

            return aStart < bEnd && bStart < aEnd && DayOverlap(a, b);
        }
Beispiel #2
0
        private bool HasDay(StudentConstraint c, Section s)
        {
            string day1 = "TBA";
            string day2 = "TBA";

            System.Diagnostics.Debug.WriteLine("Section Day is: " + s.Day);
            if (s.Day.Length > 3)
            {
                day1 = FormatDay(s.Day.Substring(0, 2)).ToLower();
                day2 = FormatDay(s.Day.Substring(2, 2)).ToLower();
            }
            else
            {
                day1 = FormatDay(s.Day).ToLower();
            }

            System.Diagnostics.Debug.WriteLine("Comparing: " + c.Day + " to " + day1 + " and " + day2);

            if (c.Day == day1)
                return true;

            if (c.Day == day2)
                return true;

            return false;
        }
Beispiel #3
0
        private bool isConstrained(Student s, Section sec)
        {
            string startHour = sec.StartTime.ToString().Split(':')[0];
            string startMinute = sec.StartTime.ToString().Split(':')[1];
            string endHour = sec.EndTime.ToString().Split(':')[0];
            string endMinute = sec.EndTime.ToString().Split(':')[1];

            System.Diagnostics.Debug.WriteLine("Section: " + startHour + ":" + startMinute + " -> " + endHour + ":" + endMinute);
            foreach (StudentConstraint constraint in s.StudentConstraints.ToList())
            {
                System.Diagnostics.Debug.WriteLine("\tCosntraint Compared: " + constraint.StartHour + " : " + constraint.StartMinute + " -> " + constraint.EndHour + ":" + constraint.EndMinute);
                if (!HasDay(constraint, sec))
                    continue;

                if (constraint.EndHour == startHour && constraint.EndMinute == startMinute)
                    return false;

                if (constraint.StartHour == endHour && constraint.StartMinute == endMinute)
                    return false;

                int startCons = Convert.ToInt32(constraint.StartHour + constraint.StartMinute);
                int endCons = Convert.ToInt32(constraint.EndHour + constraint.EndMinute);
                int startSec = Convert.ToInt32(startHour + startMinute);
                int endSec = Convert.ToInt32(endHour + endMinute);

                if (startCons < endSec && startSec < endCons)
                {
                    System.Diagnostics.Debug.WriteLine("\t\t!!!!!!!!CONSTRAINED!!!!!!!!!!!");
                    return true;
                }

            }
            return false;
        }
Beispiel #4
0
        private bool DayOverlap(Section a, Section b)
        {
            string aday1 = null;
            string aday2 = null;
            string bday1 = null;
            string bday2 = null;

            if (a.Day.Length > 2)
            {
                aday1 = FormatDay(a.Day.Substring(0, 2));
                aday2 = FormatDay(a.Day.Substring(2, 2));
            }
            else
            {
                aday1 = FormatDay(a.Day);
            }

            if (b.Day.Length > 2)
            {
                bday1 = FormatDay(b.Day.Substring(0, 2));
                bday2 = FormatDay(b.Day.Substring(2, 2));
            }
            else
            {
                bday1 = FormatDay(b.Day);
            }

            if (aday1 == bday1 || aday1 == bday2)
                return true;

            if (aday2 == bday1 || aday2 == bday2)
                return true;

            return false;
        }