static void CalculateCompleteSchedule() { int day = (int)WorkDays.Monday; int timeBlock = (int)TimeBlocks.First_Block; Course courseToPlaceInSchedule = new Course(); Schedule cSched = DataCatalogueService.CompleteSchedule; for (int i = 0; i < DataCatalogueService.CurrentlyTaughtCourses.Count; i++) { courseToPlaceInSchedule = DataCatalogueService.CurrentlyTaughtCourses[i]; if (courseToPlaceInSchedule.CheckIfSchedulesLineUp((WorkDays)day, (TimeBlocks)timeBlock)) { cSched.scheduleMatrix[day, timeBlock]._allScheduledCoursesCollection.Add(courseToPlaceInSchedule); courseToPlaceInSchedule.AddEntryToAllAssociatedSchedules((WorkDays)day, (TimeBlocks)timeBlock); day = 0; timeBlock = 0; } else { timeBlock++; if (timeBlock == Enum.GetNames(typeof(WorkDays)).Length - 1) { day++; timeBlock = 0; if (day == Enum.GetNames(typeof(TimeBlocks)).Length - 1) { UserIOController.OutputErrorMessage("Course konnte nicht platziert werden. Stundenplan generierung abgebrochen"); } } } } UserIOController.OutputMessage("Stundenplan erfolgreich erstellt."); }
// TODO Changed the entire loop, because it didn't actually loop through blocks/days // and only checked every course ONCE, so it obviously didn't work static void CalculateCompleteSchedule() { foreach (Course courseToPlace in DataCatalogueService.CurrentlyTaughtCourses) { // TODO made the looping it's own method, so I could break out of the "search for day and timeblock" part // without breaking out of the "loop through all courses" part bool couldPlace = LoopThroughScheduleAndPlaceIfPossible(courseToPlace); if (!couldPlace) { UserIOController.OutputErrorMessage("Der Kurs " + courseToPlace.Name + " konnte nicht eingetragen werden. Daten überprüfen"); } } UserIOController.OutputMessage("Stundenplan erfolgreich erstellt."); }