|
|
@ -123,4 +123,16 @@ class StudentTest { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testCalculateAverageGradeUsingTotalCredits() { |
|
|
|
Student student = new Student("John Doe", "S1001", "Student"); |
|
|
|
Course math = new Course("Math", "M101", 5); |
|
|
|
Course physics = new Course("Physics", "P101", 10); |
|
|
|
student.getCourseGrades().put(math, "15"); |
|
|
|
student.getCourseGrades().put(physics, "12"); |
|
|
|
|
|
|
|
double expectedAverage = ((15.0 * 5) + (12.0 * 10)) / (5 + 10); |
|
|
|
assertEquals(expectedAverage, student.calculateAverageGrade(), 0.01, "The calculated average grade is incorrect."); |
|
|
|
} |
|
|
|
|
|
|
|
} |