From 2e5a2eb3acbcf6653b7c36c841d2a4e00b671e17 Mon Sep 17 00:00:00 2001 From: fdai7887 Date: Thu, 8 Feb 2024 23:36:01 +0100 Subject: [PATCH] Added calculateTotalCredits Method in Student class --- src/main/java/org/example/Student.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/example/Student.java b/src/main/java/org/example/Student.java index a0b7074..4917f2e 100644 --- a/src/main/java/org/example/Student.java +++ b/src/main/java/org/example/Student.java @@ -120,4 +120,12 @@ public class Student { } } + public int calculateTotalCredits() { + int totalCredits = 0; + for (Course course : courseGrades.keySet()) { + totalCredits += course.getCourseCredits(); + } + return totalCredits; + } + }