Exemple #1
0
    internal double CalculateGrade(string courseName)
    {
        int[]  scores = ScoresByCourse.First(c => c.Key == courseName).Value;
        double grade  = (scores.Average() / 100) * 4 + 2;

        return(grade);
    }
Exemple #2
0
 internal void SetScoresForCourse(string courseName, int[] newScores)
 {
     if (!ScoresByCourse.ContainsKey(courseName))
     {
         throw new StudentNotEnrolledInCourseException(Name, courseName);
     }
     else if (newScores.Length > Course.NumberOfTasksPerExam)
     {
         throw new InvalidNumberOfScoresException(Name, courseName);
     }
     else
     {
         int[] oldScores = ScoresByCourse.First(c => c.Key == courseName).Value;
         for (int s = 0; s < newScores.Length; s++)
         {
             if (newScores[s] > oldScores[s])
             {
                 oldScores[s] = newScores[s];
             }
         }
     }
 }