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