コード例 #1
0
        public Semester Execute()
        {
            using (StreamReader sr = new StreamReader(Filename))
            {
                string   line   = sr.ReadLine();
                string[] tokens = line.Split(new char[] { ' ', ',' });
                Semester newSem = new Semester(tokens[0], Convert.ToInt32(tokens[1]));

                //Get to first line
                line = sr.ReadLine();
                line = sr.ReadLine();
                ArrayList Courses     = new ArrayList();
                ArrayList Instructors = new ArrayList();
                ArrayList Facilities  = new ArrayList();
                bool      exists      = false;
                while (line != null)
                {
                    //Course
                    tokens = line.Split(',');
                    string Subject    = tokens[0];
                    int    CatalogNbr = Convert.ToInt32(tokens[1]);
                    string ClassDescr = tokens[2];

                    //Instructor
                    string InstructorName = tokens[4] + tokens[5];
                    InstructorName = InstructorName.Substring(1, InstructorName.Length - 2);

                    //Facility
                    string Building = "";
                    string Room     = "";
                    for (int i = 0; i < tokens[11].Length; i++)
                    {
                        if (!Char.IsDigit(tokens[11][i]))
                        {
                            Building += tokens[11][i];
                        }
                        else if (Room.Equals("") && !tokens[11].Substring(i).Equals(""))
                        {
                            Room = tokens[11].Substring(i);
                        }
                    }

                    //Section
                    string Section          = tokens[3];
                    string Consent          = tokens[6];
                    int    EnrlCap          = Convert.ToInt32(tokens[7]);
                    string TopicDescr       = tokens[8];
                    string MeetingStartDt   = tokens[9];
                    string MeetingEndDt     = tokens[10];
                    string MeetingTimeStart = tokens[12];
                    string MeetingTimeEnd   = tokens[13];
                    bool[] Days             = new bool[7];
                    for (int i = 0; i < 7; i++)
                    {
                        Days[i] = tokens[14 + i][0] == 'Y';
                    }
                    int    UnitsMin           = Convert.ToInt32(tokens[21]);
                    int    UnitsMax           = Convert.ToInt32(tokens[22]);
                    string ClassAssnComponent = tokens[23];
                    line = sr.ReadLine();

                    Course     tempCourse     = null;
                    Instructor tempInstructor = null;
                    Facility   tempFacility   = null;

                    //Find the Course indicated from file
                    foreach (Course c in Courses)
                    {
                        if (!exists && c.Subject.Equals(Subject) && c.CatalogNbr == CatalogNbr && c.ClassDescr.Equals(ClassDescr))
                        {
                            exists = true; tempCourse = c;
                        }
                    }
                    if (!exists)
                    {
                        tempCourse = new Course(Subject, CatalogNbr, ClassDescr);
                    }
                    exists = false;

                    //Find the Instructor indicated from file
                    foreach (Instructor i in Instructors)
                    {
                        if (!exists && i.Name.Equals(InstructorName))
                        {
                            exists = true; tempInstructor = i;
                        }
                    }
                    if (!exists)
                    {
                        tempInstructor = new Instructor(InstructorName);
                    }
                    exists = false;

                    //Find the Facility indicated from file
                    foreach (Facility f in Facilities)
                    {
                        if (!exists && f.Building.Equals(Building) && f.Room.Equals(Room))
                        {
                            exists = true; tempFacility = f;
                        }
                    }
                    if (!exists)
                    {
                        tempFacility = new Facility(Building, Room);
                    }

                    //Create a Section
                    Section Sect = new Section(Section, Consent, EnrlCap, TopicDescr, MeetingStartDt, MeetingEndDt,
                                               MeetingTimeStart, MeetingTimeEnd, Days, UnitsMin, UnitsMax, ClassAssnComponent, tempInstructor, tempFacility, newSem, tempCourse);
                }
                return(newSem);
            }
        }
コード例 #2
0
ファイル: Section.cs プロジェクト: WestonChan/501Final
        public Section(string SectionNumber, string Consent, int EnrlCap, string TopicDescr, string MeetingStartDt,
                       string MeetingEndDt, string MeetingTimeStart, string MeetingTimeEnd, bool[] Days, int UnitsMin,
                       int UnitsMax, string ClassAssnComponent, Instructor Teach, Facility Place, Semester Sem, Course Cor)
        {
            this.SectionNumber      = SectionNumber;
            this.Consent            = Consent;
            this.EnrlCap            = EnrlCap;
            this.TopicDescr         = TopicDescr;
            this.MeetingStartDt     = MeetingStartDt;
            this.MeetingEndDt       = MeetingEndDt;
            this.MeetingTimeStart   = MeetingTimeStart;
            this.MeetingTimeEnd     = MeetingTimeEnd;
            this.Days               = Days;
            this.UnitsMin           = UnitsMin;
            this.UnitsMax           = UnitsMax;
            this.ClassAssnComponent = ClassAssnComponent;

            this.Teach = Teach;
            this.Place = Place;
            this.Sem   = Sem;
            this.Cor   = Cor;

            Teach.Sections.Add(this);
            Place.Sections.Add(this);
            Sem.Sections.Add(this);
            Cor.Sections.Add(this);
        }
コード例 #3
0
ファイル: Clear.cs プロジェクト: WestonChan/501Final
 public Clear(out Semester local, out Semester ksis)
 {
     local = null;
     ksis  = null;
 }
コード例 #4
0
ファイル: Verify.cs プロジェクト: WestonChan/501Final
 public Verify(Semester local, Semester ksis)
 {
     this.local = local;
     this.ksis  = ksis;
 }
コード例 #5
0
 public bool Equals(Semester other)
 {
     return(Name.Equals(other.Name) && Year == other.Year);
 }