private List <PossibleCourse> GetPossibleCourses() { List <PossibleCourse> possibleCourses = new List <PossibleCourse>(); foreach (var row in dataBaseHandler.DataSet.PossibleCourses) { Course course = new Course(dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).CourseID, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).Name, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).Credits, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).NeedsLabRoom, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).NeedsLargeRoom, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).IsElective, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).Hasrerequisite, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).Major, dataBaseHandler.DataSet.Courses.FindByCourseID(row.CourseID).Capacity); Instructor instructor = new Instructor(dataBaseHandler.DataSet.Instructors.FindByInstructorID(row.InstructorID).Name, dataBaseHandler.DataSet.Instructors.FindByInstructorID(row.InstructorID).InstructorID, dataBaseHandler.DataSet.Instructors.FindByInstructorID(row.InstructorID).maxClasses); Room room = new Room(dataBaseHandler.DataSet.Rooms.FindByRoomID(row.RoomID).RoomID, dataBaseHandler.DataSet.Rooms.FindByRoomID(row.RoomID).IsLarge, dataBaseHandler.DataSet.Rooms.FindByRoomID(row.RoomID).IsLab); PossibleCourse possibleCourse = new PossibleCourse(course, instructor, row.TimeStart, row.TimeEnd, row.DateOffered, room); //Is possible courses table even needed? possibleCourses.Add(possibleCourse); } return(possibleCourses); }
public Schedule generateScheduleLvl1(List <Course> courseList, List <Instructor> instructorList, List <Room> roomList) { courseList = randomizeCourses(courseList); List <PossibleCourse> possibleCoursesList = new List <PossibleCourse>(); Room possibleRoom = null; int c = 0; //For loop through instuctors and assign as many courses until limit of courses per instructor is met //Given the room is available and times are not conflicting //1.For each instructor for (int i = 0; i < instructorList.Count; i++) { int startTime = 8; int endTime = 10; string weekDays = "MW"; //Counter to compare to a instructors maximum classes they can teach int maxCoursesCounter = 0; //2.Look through all the courses and the professor isn't maxed for (; c < courseList.Count && maxCoursesCounter < instructorList[i].maxCourses; c++) { bool keepGoing = true; //4. If the room is available for (int r = 0; r < roomList.Count && keepGoing; r++) { if (courseList[c].NeedsLabRoom && roomList[r].isLab) { if (roomList[r].roomAvailbility[weekDays + startTime]) { roomList[r].roomAvailbility[weekDays + startTime] = false; possibleRoom = roomList[r]; keepGoing = false; } } else if (courseList[c].NeedsLargeRoom && roomList[r].isLarge) { if (roomList[r].roomAvailbility[weekDays + startTime]) { roomList[r].roomAvailbility[weekDays + startTime] = false; possibleRoom = roomList[r]; keepGoing = false; } } else { if (roomList[r].roomAvailbility[weekDays + startTime]) { roomList[r].roomAvailbility[weekDays + startTime] = false; possibleRoom = roomList[r]; keepGoing = false; } } } //5. Assign a time // //6. Add the course //Fix the possible room != null if (possibleRoom != null) { PossibleCourse possibleCourse = new PossibleCourse(courseList[c], instructorList[i], startTime, endTime, weekDays, possibleRoom); possibleCoursesList.Add(possibleCourse); //Remove the course from the list to prevent multiple //instructors being assigned the same course //courseList.RemoveAt(c); maxCoursesCounter++; } startTime += 2; endTime += 2; if (endTime == 16) { weekDays = "TTH"; startTime = 8; endTime = 10; } } } Schedule schedule = new Schedule(possibleCoursesList, 100); return(schedule); }