public void crossSchoolTimeTables(SchoolTimeTable stt1, SchoolTimeTable stt2) { foreach (TimeTable tt1 in stt1.groupTimeTables) { TimeTable tt2 = null; foreach (TimeTable tt2_tmp in stt2.groupTimeTables) { if (tt1.group.Equals(tt2_tmp.group)) { tt2 = tt2_tmp; break; } } if (tt2 != null) { //tt1.printTimeTable(); //tt2.printTimeTable(); List <TimeSlot> slots = getTheSameTimeSlotInTheSameLesson(tt1, tt2); foreach (TimeSlot slot in slots) { Lesson lesson = tt1.getLesson(slot.day, slot.hour)[0]; if (lesson.getSize() == 1) { TimeTable teacherTimeTable = null; foreach (TimeTable teacherTT in this.teacherTimeTables) { if (teacherTT.Equals(lesson.getTeacher())) { teacherTimeTable = teacherTT; break; } } TimeTable groupTimeTable = null; foreach (TimeTable groupTT in this.groupTimeTables) { if (groupTT.Equals(lesson.getGroup())) { groupTimeTable = groupTT; break; } } teacherTimeTable.addLesson(lesson, slot.day, slot.hour); groupTimeTable.addLesson(lesson, slot.day, slot.hour); } } } } lessons = getListOfLessonToInsert(); this.generateSchoolTimeTable(); //this.printTimeTable(); }
public int schoolTimeTableComparator(SchoolTimeTable l1, SchoolTimeTable l2) { return(l1.getValue().CompareTo(l2.getValue())); }
// public SchoolTimeTable(List <Lesson> lessons, List <Teacher> teachers, List <Group> groups, SchoolTimeTable stt) : this(lessons, teachers, groups) { for (int i = 0; i < stt.groupTimeTables.Count; ++i) { TimeTable gtt = stt.groupTimeTables[i]; for (int d = 0; d < ConstVariable.NUMBER_OF_DAYS; ++d) { for (int h = 0; h < ConstVariable.NUMBER_OF_SLOTS_IN_DAY; ++h) { if (gtt.getLesson(d, h).Count > 0) { Lesson tmp = gtt.getLesson(d, h)[0]; int index = this.lessons.IndexOf(tmp); Lesson tmpT = this.lessons[index]; this.groupTimeTables[i].addLesson(tmpT, d, h); this.teacherTimeTables[getIndexOfTeacher(tmpT.getTeacher())].addLesson(tmpT, d, h); } } } } }