internal double CalculateStudentGrade(string studentName) { int[] scores = ScoresByStudent.First(s => s.Key == studentName).Value; double grade = (scores.Average() / 100) * 4 + 2; return(grade); }
internal void EnrollStudent(string studentName) { if (ScoresByStudent.Any(s => s.Key == studentName)) { throw new StudentAlreadyEnrolledInCourseException(studentName, Name); } else { ScoresByStudent.Add(studentName, new int[NumberOfTasksPerExam]); } }
internal void SetScoresForStudent(string studentName, int[] newScores) { if (!ScoresByStudent.ContainsKey(studentName)) { throw new StudentNotEnrolledInCourseException(studentName, Name); } else if (newScores.Length > NumberOfTasksPerExam) { throw new InvalidNumberOfScoresException(studentName, Name); } else { int[] oldScores = ScoresByStudent.First(s => s.Key == studentName).Value; for (int s = 0; s < newScores.Length; s++) { if (newScores[s] > oldScores[s]) { oldScores[s] = newScores[s]; } } } }