/// <summary> /// Constructs the week's timetable for the specified courses and returns the timetable object on success. /// </summary> /// <param name="courses"> /// The list of courses for which to generate the timetable. /// </param> /// <returns></returns> public static Timetable GetTimetable(IEnumerable<Course> courses) { try { Timetable timetable = new Timetable(); foreach (Course c in courses) { LtpCourse course = c as LtpCourse; if (course != null) { BitArray punchCard = new BitArray(7); // Adding the schedule of regular classes of the current courses. foreach (ClassHours classHours in course.Timings) { int i = (int)classHours.Day; timetable._weekRegularClasses[i].Add(classHours); punchCard[i] = true; } // Adding the course to those days which do not have a regular class of the current course. for (int i = 0; i < 7; i++) { if (punchCard[i] == false) timetable._weekNeglectedCourses[i].Add(course); } } } foreach (var daySchedule in timetable._weekRegularClasses) daySchedule.Sort(); return timetable; } catch { return null; } }