Example #1
0
        public void ReMerge()
        {
            CourseTimes.Clear();
            int       timePointCount = TimePoints.Count;
            int       tempSpan       = 0;
            TimePoint tempPoint      = new TimePoint(-1, -1);

            for (int i = 0; i < timePointCount; i++)
            {
                if (TimePoints[i].DayOfWeek == tempPoint.DayOfWeek && TimePoints[i].ClassOfDay == (tempPoint.ClassOfDay + tempSpan) && TimePoints[i].WeekKind == tempPoint.WeekKind)
                {
                    tempSpan++;
                }
                else
                {
                    if (tempPoint.DayOfWeek != -1)
                    {
                        CourseTimes.Add(new CourseTime(tempPoint.DayOfWeek, tempPoint.ClassOfDay, tempSpan, tempPoint.WeekKind));
                    }
                    tempPoint = TimePoints[i];
                    tempSpan  = 1;
                }
            }
            CourseTimes.Add(new CourseTime(tempPoint.DayOfWeek, tempPoint.ClassOfDay, tempSpan, tempPoint.WeekKind));
        }
Example #2
0
 public void AddTime(CourseTime time)
 {
     CourseTimes.Add(time);
     for (int i = time.Start; i <= time.End; i++)
     {
         TimePoints.Add(new TimePoint(time.Day, i, time.Week));
     }
 }
Example #3
0
 public void Merge()
 {
     CourseTimes.Clear();
     TimePoints.Sort((a, b) =>
     {
         if (a.DayOfWeek != b.DayOfWeek)
         {
             return(Math.Sign(a.DayOfWeek - b.DayOfWeek));
         }
         return(Math.Sign(a.ClassOfDay - b.ClassOfDay));
     });
     ReMerge();
 }