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); } }
public void MakeClass() { ScheduleClass sc = new ScheduleClass(); Console.WriteLine("-----New Class-----"); Console.WriteLine("Class Title?"); sc.Title = Console.ReadLine(); Console.WriteLine("Class Subject Number?"); sc.Subject = Int32.Parse(Console.ReadLine()); Console.WriteLine("Class Index Number?"); sc.Index = Int32.Parse(Console.ReadLine()); Console.WriteLine("How many sections of this class exist?"); int sectionCount = Int32.Parse(Console.ReadLine()); for (int i = 0; i < sectionCount; i++) { sc.Sections.Add(EnterClassSection()); sc.Sections[sc.Sections.Count - 1].parentClass = sc; } classList.Add(sc); }
int GetIndexForClass(ScheduleClass cs) { for (int i = 0; i < classList.Count; i++) { if (classList[i].Title == cs.Title && classList[i].Subject == cs.Subject && classList[i].Index == cs.Index) { return i; } } return -1; }