private CourseClass(Professor professor, Course course, List<StudentGroup> groups, bool requiresLab, int duration, int id) { ID = id; ClassProfessor = professor; ClassCourse = course; StudentGroups = groups; RequiresLab = requiresLab; Length = duration; }
public CourseClass(Professor professor, Course course, List<StudentGroup> groups, bool requiresLab, int duration) { ID = _nextID++; ClassProfessor = professor; ClassCourse = course; StudentGroups = groups; RequiresLab = requiresLab; Length = duration; }
public void ReadFromXML(string path) { XElement doc = XElement.Load(path); var professors = from el in doc.Elements() where el.Name == "prof" select el; var courses = from el in doc.Elements() where el.Name == "course" select el; var rooms = from el in doc.Elements() where el.Name == "room" select el; var groups = from el in doc.Elements() where el.Name == "group" select el; var classes = from el in doc.Elements() where el.Name == "class" select el; foreach (var prof in professors) { string name = prof.Attribute("name").Value; int id = int.Parse(prof.Attribute("id").Value); Professor p = new Professor(id, name); Professors.Add(id, p); } foreach (var course in courses) { string name = course.Attribute("name").Value; int id = int.Parse(course.Attribute("id").Value); Course c = new Course(id, name); Courses.Add(id, c); } foreach (var room in rooms) { string name = room.Attribute("name").Value; int cap = int.Parse(room.Attribute("capacity").Value); bool lab = bool.Parse(room.Attribute("lab").Value); Room r = new Room(name, lab, cap); Rooms.Add(r.ID, r); } foreach (var group in groups) { string name = group.Attribute("name").Value; int id = int.Parse(group.Attribute("id").Value); int size = int.Parse(group.Attribute("size").Value); StudentGroup g = new StudentGroup(id, name, size); StudentGroups.Add(id, g); } foreach (var cclass in classes) { int dur = int.Parse(cclass.Attribute("dur").Value); bool requireslab = bool.Parse(cclass.Attribute("requireslab").Value); var prof = GetProfessorByID(int.Parse(cclass.Attribute("professor").Value)); var group = GetStudentGroupByID(int.Parse(cclass.Attribute("group").Value)); var course = GetCourseByID(int.Parse(cclass.Attribute("course").Value)); CourseClass c = new CourseClass(prof, course, new List<StudentGroup> { group }, requireslab, dur); CourseClasses.Add(c); group.Classes.Add(c); prof.Classes.Add(c); } }