Пример #1
0
        static void GPAOption(Grades_Handler gH, Student_Handler sH)
        {
            foreach (Student student in sH.getAllStudents())
            {
                float finalSum  = 0;
                int   courseCnt = 0;

                foreach (Grades grades in gH.getGradesFromStudent(student.getID()))
                {
                    finalSum += grades.Grade_final;
                    courseCnt++;
                }

                Console.WriteLine(student.getName() + "'s GPA: " + finalSum / courseCnt);
                Console.WriteLine("Press any key to continue....");
                Console.ReadKey();
            }
        }
Пример #2
0
        static void gradeOption(Grades_Handler gH, Student_Handler sH, Course_Handler cH)
        {
            String sInput;
            int    sID, options, cID;

            do
            {
                Console.WriteLine("Which student's grade do you want to see?");

                foreach (Student student in sH.getAllStudents())
                {
                    Console.WriteLine("ID: " + student.getID());
                }

                sInput = Console.ReadLine();
                int.TryParse(sInput, out sID);

                ArrayList courses = cH.getAllCourses();

                foreach (Grades grades in gH.getGradesFromStudent(sID))
                {
                    Course course = (Course)courses[grades.CID];
                    Console.WriteLine("Course: " + course.getName());
                    Console.WriteLine("Exercises Grade: " + grades.Exercises);
                    Console.WriteLine("Exams Grade: " + grades.Exams);
                    Console.WriteLine("Finals Exam Grade: " + grades.Finals);
                    Console.WriteLine("Final Grade: " + grades.Grade_final);
                    Console.WriteLine();
                }

                Console.WriteLine("1. Add a gradebook");
                Console.WriteLine("2. Edit a gradebook");
                Console.WriteLine("3. Delete a gradebook");
                Console.WriteLine("4. Back");

                sInput = Console.ReadLine();
                int.TryParse(sInput, out options);
                Console.Clear();

                float exercises, exams, finals_exam, final_grade;
                switch (options)
                {
                case 1:
                    foreach (Course course in cH.getAllCourses())
                    {
                        Console.WriteLine(course.getID() + " " + course.getName());
                    }

                    sInput = Console.ReadLine();
                    int.TryParse(sInput, out cID);

                    Console.WriteLine("Exercises: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out exercises);
                    Console.WriteLine("Exams: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out exams);
                    Console.WriteLine("Finals Exams: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out finals_exam);
                    Console.WriteLine("Final Grade: ");
                    Single.TryParse(sInput, out final_grade);

                    gH.addGrades(new Grades(sID, cID, exercises, exams, finals_exam, final_grade));
                    break;

                case 2:
                    foreach (Course course in cH.getAllCourses())
                    {
                        Console.WriteLine(course.getID() + " " + course.getName());
                    }

                    sInput = Console.ReadLine();
                    int.TryParse(sInput, out cID);

                    Console.WriteLine("Exercises: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out exercises);
                    Console.WriteLine("Exams: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out exams);
                    Console.WriteLine("Finals Exams: ");
                    sInput = Console.ReadLine();
                    Single.TryParse(sInput, out finals_exam);
                    Console.WriteLine("Final Grade: ");
                    Single.TryParse(sInput, out final_grade);

                    gH.editGrades(sID, cID, new Grades(sID, cID, exercises, exams,
                                                       finals_exam, final_grade));
                    break;

                case 3:
                    foreach (Course course in cH.getAllCourses())
                    {
                        Console.WriteLine(course.getID() + " " + course.getName());
                    }

                    sInput = Console.ReadLine();
                    int.TryParse(sInput, out cID);

                    gH.deleteGrades(sID, cID);

                    break;
                }
            } while (options != 0);
        }