public List<ClassSection> DoesClassConflict(ClassSection sc) { Dictionary<string, ClassSection> conflictList = new Dictionary<string, ClassSection>(); List<ClassSection> ListOfConflicts = new List<ClassSection>(); foreach (ClassSection c in classes) { foreach (TimeFrame newTimes in sc.Times) { foreach (TimeFrame oldTimes in c.Times) { if (newTimes.DoesOverlap(oldTimes)) { if (!conflictList.ContainsKey(c.parentClass.Index.ToString() + ":" + c.parentClass.Subject.ToString())) { conflictList.Add(c.parentClass.Index.ToString() + ":" + c.parentClass.Subject.ToString(), c); ListOfConflicts.Add(c); } } } } } return ListOfConflicts; }
ClassSection EnterClassSection() { ClassSection cs = new ClassSection(); Console.WriteLine("Enter section number"); cs.Section = Console.ReadLine(); Console.WriteLine("How many times does this section meet?"); int meetCount = Int32.Parse(Console.ReadLine()); for (int i = 0; i < meetCount; i++) { cs.Times.Add(EnterTimeFrame()); } return cs; }
public void LoadXMLClassList(string filename) { System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument(); xdoc.Load(filename); System.Xml.XmlElement root = (System.Xml.XmlElement)xdoc.ChildNodes[1]; foreach (System.Xml.XmlElement classNode in root.ChildNodes) { ScheduleClass sc = new ScheduleClass(); sc.Title = classNode.Attributes["Title"].Value; sc.Subject = Int32.Parse(classNode.Attributes["Subject"].Value); sc.Sch = Int32.Parse(classNode.Attributes["Sch"].Value); sc.Index = Int32.Parse(classNode.Attributes["Index"].Value); sc.Credits = Int32.Parse(classNode.Attributes["Credits"].Value); foreach (System.Xml.XmlElement scheduleNode in classNode.ChildNodes) { ClassSection cs = new ClassSection(); cs.parentClass = sc; cs.Section = scheduleNode.Attributes["SectionCode"].Value; cs.RegistrationIndex = scheduleNode.Attributes["RegistrationIndex"].Value; foreach (System.Xml.XmlElement timeframeNode in scheduleNode.ChildNodes) { TimeFrame tf = new TimeFrame(); tf.StartTime = new WeeklyTime((DayOfWeek)Enum.Parse(typeof(DayOfWeek), timeframeNode.Attributes["startDay"].Value, true), Int32.Parse(timeframeNode.Attributes["startHour"].Value), Int32.Parse(timeframeNode.Attributes["startMin"].Value)); tf.EndTime = new WeeklyTime((DayOfWeek)Enum.Parse(typeof(DayOfWeek), timeframeNode.Attributes["startDay"].Value, true), Int32.Parse(timeframeNode.Attributes["endHour"].Value), Int32.Parse(timeframeNode.Attributes["endMin"].Value)); cs.Times.Add(tf); } sc.Sections.Add(cs); } classList.Add(sc); } }