From fe4b78b1eaecc5f63894c428788045d1cc421e64 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Thu, 8 Feb 2024 17:48:30 +0100 Subject: [PATCH] refactoring: Changed to Map instead of list to store both Course and grades --- src/main/java/org/example/Student.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/example/Student.java b/src/main/java/org/example/Student.java index 70db548..fd76b0d 100644 --- a/src/main/java/org/example/Student.java +++ b/src/main/java/org/example/Student.java @@ -2,7 +2,9 @@ package org.example; import java.io.*; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Represents an student user in the system. @@ -12,7 +14,7 @@ public class Student { String studentName; String studentId; String studentRole; - List courses = new ArrayList<>(); + Map courseGrades = new HashMap<>(); public Student(){ @@ -55,12 +57,12 @@ public class Student { this.studentRole = studentRole; } - public List getCourses() { - return courses; + public Map getCourseGrades() { + return courseGrades; } - public void setCourses(List courses) { - this.courses = courses; + public void setCourseGrades(Map courseGrades) { + this.courseGrades = courseGrades; } /**