Exemplo n.º 1
0
        // Making changes to the object //
        public void addClassToPast(previousCourse pcrs)
        {
            // Don't have to branch on "S15" and "F14" because addPrevCourses function already does
            // Sorry!!

            //TO-DO UPDATE CALCULATE GPA FUNCTION TO BE HERE. ALSO INCREMENT TOTAL CREDITS
            pastCrs.Add(pcrs);
        }
Exemplo n.º 2
0
        public void addPrevCourses(ref courseDatabase crsDB, string nextSemester)
        {
            string line;

            System.IO.StreamReader input = new System.IO.StreamReader(@"..\..\historyDB.in");
            while ((line = input.ReadLine()) != null)
            {
                string username     = line.Substring(0, 10).Trim().ToLower(); // Needed ToLower()
                string courseNumStr = line.Substring(11, 2).Trim();
                int    courseNum    = int.Parse(courseNumStr);
                int    loc          = 14;

                student std = stdLst.Find(s => s.username.Trim() == username);

                for (int i = 0; i < courseNum; i++)
                {
                    string crsID = line.Substring(loc, 10).Trim();
                    loc += 11;
                    string semester = line.Substring(loc, 3).Trim();
                    loc += 4;
                    string creditStr = line.Substring(loc, 4).Trim();
                    float  credit    = float.Parse(creditStr);
                    loc += 4;
                    string grade;
                    if ((line.Length - loc) >= 3)
                    {
                        grade = line.Substring(loc, 3).Trim().ToString();
                    }
                    else
                    {
                        grade = line.Substring(loc).Trim().ToString();
                    }
                    loc += 5;
                    if (semester == nextSemester)
                    {
                        course crs = crsDB.getCourse(crsID);
                        std.addClassToNext(crs);
                        crs.enrollUser(std);
                    }
                    else if (semester == "F14")
                    {
                        previousCourse pcrs = new previousCourse(username, crsID, semester, credit, grade);
                        std.addClassToCurrent(pcrs);
                    }
                    else
                    {
                        previousCourse currentCourse = new previousCourse(username, crsID, semester, credit, grade);
                        std.addClassToPast(currentCourse);
                    }
                }
            }
            input.Close();
            foreach (student std in stdLst)
            {
                std.calculateGPA();
            }
        }
Exemplo n.º 3
0
 public void addClassToCurrent(previousCourse pcrs)
 {
     currentCrs.Add(pcrs);
 }