Example #1
0
        static void TopStudentsOption(Grades_Handler gH, Course_Handler cH, Student_Handler sH)
        {
            String sInput;
            int    cID;

            Console.WriteLine("Which course?");
            foreach (Course course in cH.getAllCourses())
            {
                Console.WriteLine(course.getID() + ".");
            }

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

            List <Top5> Top5List = new List <Top5>();

            foreach (Student student in sH.getAllStudents())
            {
                Grades grades = gH.getGradesFromStudentAndCourse(student.getID(), cID);
                if (grades != null)
                {
                    if (Top5List.Capacity != 5)
                    {
                        Top5List.Add(new Top5()
                        {
                            name = student.getName(), Grade = grades.Grade_final
                        });
                    }
                    else
                    {
                        foreach (Top5 top5 in Top5List)
                        {
                            if (grades.Grade_final > top5.Grade)
                            {
                                Top5List.Remove(top5);
                                Top5List.Add(new Top5()
                                {
                                    name = student.getName(), Grade = grades.Grade_final
                                });
                            }
                            break;
                        }
                    }
                }
            }

            Top5List.OrderBy(Top5 => Top5.Grade);

            Console.WriteLine("Top 5 is: ");

            foreach (Top5 top5 in Top5List)
            {
                Console.WriteLine(top5.name + " " + top5.Grade);
            }

            Console.WriteLine("Press any key to continue....");
            Console.ReadKey();
        }
Example #2
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();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Student_Handler sH = new Student_Handler();
            Course_Handler  cH = new Course_Handler();
            Grades_Handler  gH = new Grades_Handler();

            int input;

            do
            {
                Console.Clear();
                Console.WriteLine("What do you want to do?");
                Console.WriteLine("1. Students");
                Console.WriteLine("2. Courses");
                Console.WriteLine("3. Grades");
                Console.WriteLine("4. GPA per Student");
                Console.WriteLine("5. GPA per Course");
                Console.WriteLine("6. Top 5 Students per Course");
                Console.WriteLine("0. Exit");

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

                Console.Clear();

                switch (input)
                {
                case 0:
                    break;

                case 1:
                    studentOption(sH);
                    break;

                case 2:
                    courseOption(cH);
                    break;

                case 3:
                    gradeOption(gH, sH, cH);
                    break;

                case 4:
                    GPAOption(gH, sH);
                    break;

                case 5:
                    PerCourseOption(gH, cH);
                    break;

                case 6:
                    TopStudentsOption(gH, cH, sH);
                    break;

                default:
                    Console.WriteLine("INVALID INPUT!");
                    break;
                }
            } while (input != 0);

            List <String> students = new List <String>();

            foreach (Student student in sH.getAllStudents())
            {
                students.Add(student.getID().ToString() + "," + student.getName() + "," + student.getGender());
            }

            String[] sToFile;
            sToFile = (String[])students.ToArray();

            File.WriteAllLines("Resources\\Student.txt", sToFile);

            List <String> courses = new List <String>();

            foreach (Course course in cH.getAllCourses())
            {
                courses.Add(course.getID().ToString() + "," + course.getName() + "," + course.getCode());
            }

            String[] cToFile;
            cToFile = (String[])courses.ToArray();

            File.WriteAllLines("Resources\\Courses.txt", cToFile);

            List <String> gradesList = new List <String>();

            foreach (Grades grades in gH.getAllGrades())
            {
                gradesList.Add(grades.SID.ToString() + "," + grades.CID.ToString() + "," + grades.Exercises.ToString() + "," + grades.Exams.ToString() + "," + grades.Finals.ToString() + "," + grades.Grade_final.ToString());
            }

            String[] gToFile;
            gToFile = (String[])gradesList.ToArray();

            File.WriteAllLines("Resources\\Grades.txt", gToFile);


            Environment.Exit(0);
        }
Example #4
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);
        }
Example #5
0
        static void studentOption(Student_Handler sH)
        {
            String sInput;
            int    input2;
            int    tempID;

            do
            {
                Console.WriteLine("1. Add Student");
                Console.WriteLine("2. Edit Student");
                Console.WriteLine("3. Delete Student");
                Console.WriteLine("0. Back");

                Student student = new Student();

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

                Console.Clear();


                switch (input2)
                {
                case 0:
                    break;

                case 1:
                    Console.WriteLine("Name?");
                    student.setName(Console.ReadLine());
                    Console.WriteLine("Gender?");
                    student.setGender(Console.ReadLine());

                    sH.AddStudent(student.getName(), student.getGender());
                    break;

                case 2:

                    foreach (Student tempStudent in sH.getAllStudents())
                    {
                        Console.WriteLine("ID: " + tempStudent.getID());
                    }
                    Console.WriteLine("Which one will you edit?");
                    sInput = Console.ReadLine();
                    int.TryParse(sInput, out tempID);
                    Console.WriteLine("Name?");
                    student.setName(Console.ReadLine());
                    Console.WriteLine("Gender?");
                    student.setGender(Console.ReadLine());

                    sH.EditStudent(tempID, student.getName(), student.getGender());

                    break;

                case 3:
                    foreach (Student tempStudent in sH.getAllStudents())
                    {
                        Console.WriteLine("ID: " + tempStudent.getID());
                    }
                    Console.WriteLine("Which one will you delete?");
                    sInput = Console.ReadLine();
                    int.TryParse(sInput, out tempID);

                    sH.deleteStudent(tempID);

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