Ejemplo n.º 1
0
        static void addStudent()
        {
            Console.Clear();
            Console.Write("Please enter name: ");
            String name = Console.ReadLine();
            Console.Write("Please enter ID: ");
            String id = Console.ReadLine();
            Console.Write("Please enter gender: ");
            String gender = Console.ReadLine();
            Student s = new Student(name, id, gender);

            foreach (string str in gradebooks)
            {
                s.addGrade(new Grade(str));
            }
            students.Add(s);
        }
Ejemplo n.º 2
0
        public static List<Student> readFromFile()
        {
            List<Student> students = new List<Student>();
            try
            {
                using (StreamReader sr = new StreamReader("Gradebook.txt"))
                {
                    int nStudents = Int32.Parse(sr.ReadLine());
                    int nCourses = Int32.Parse(sr.ReadLine());
                    List<string> courses = new List<string>();

                    for (int i = 0; i < nCourses; i++)
                    {
                        courses.Add(sr.ReadLine());
                    }

                    for (int i = 0; i < nStudents; i++)
                    {
                        Student s = new Student(sr.ReadLine(), sr.ReadLine(), sr.ReadLine());
                        foreach (string course in courses)
                        {
                            Grade g = new Grade(course);
                            g.ExerciseScore = Double.Parse(sr.ReadLine());
                            g.ExamScore = Double.Parse(sr.ReadLine());
                            g.FinalsScore = Double.Parse(sr.ReadLine());
                            g.FinalGrade = Double.Parse(sr.ReadLine());
                            s.addGrade(g);
                        }
                        students.Add(s);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
            return students;
        }
Ejemplo n.º 3
0
 static void viewStudent(Student s)
 {
     Console.Clear();
     Console.WriteLine("Name: "+s.Name);
     Console.WriteLine("ID: "+s.Id);
     Console.WriteLine("Gender: "+s.Gender);
     Console.WriteLine("Grades:");
     List<Grade> studentGrades = s.getGrades();
     int i = 1;
     foreach (Grade g in studentGrades)
     {
         Console.WriteLine(i+++": "+g.ToString());
     }
     Console.WriteLine("GPA: " + s.calculateGPA());
     Console.Write("Choose a course to edit by entering its number, exit by entering anything else: ");
     try
     {
         int index = Int32.Parse(Console.ReadLine()) - 1;
         if (index >= 0 && index < studentGrades.Count)
         {
             Grade g = s.getGrades()[index];
             editGrade(g);
         }
     }
     catch { }
 }