예제 #1
0
    internal double CalculateStudentGrade(string studentName)
    {
        int[]  scores = ScoresByStudent.First(s => s.Key == studentName).Value;
        double grade  = (scores.Average() / 100) * 4 + 2;

        return(grade);
    }
예제 #2
0
 internal void EnrollStudent(string studentName)
 {
     if (ScoresByStudent.Any(s => s.Key == studentName))
     {
         throw new StudentAlreadyEnrolledInCourseException(studentName, Name);
     }
     else
     {
         ScoresByStudent.Add(studentName, new int[NumberOfTasksPerExam]);
     }
 }
예제 #3
0
 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];
             }
         }
     }
 }