示例#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);
    }
示例#2
0
 internal void EnrollInCourse(string courseName)
 {
     if (ScoresByCourse.ContainsKey(courseName))
     {
         throw new StudentAlreadyEnrolledInCourseException(Name, courseName);
     }
     else
     {
         ScoresByCourse.Add(courseName, new int[Course.NumberOfTasksPerExam]);
     }
 }
示例#3
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];
             }
         }
     }
 }