From 5e75c4c2164f22a475565a82c99ef29a81991590 Mon Sep 17 00:00:00 2001 From: fdai7887 Date: Fri, 9 Feb 2024 00:27:38 +0100 Subject: [PATCH] Improved Documentation in Student class --- src/main/java/org/example/Student.java | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/example/Student.java b/src/main/java/org/example/Student.java index 4917f2e..946f5fd 100644 --- a/src/main/java/org/example/Student.java +++ b/src/main/java/org/example/Student.java @@ -33,6 +33,10 @@ public class Student { this.studentRole = role; } + /** + * Various setter and getter for Student class + * + */ public String getStudentName() { return studentName; } @@ -77,7 +81,12 @@ public class Student { System.out.println("Role: " + getStudentRole()); } - + /** + * Writes Data of a Student to a File + * @param student The Student whose data is being written + * @param filename The Name of the File to which the data is written + * @throws IOException + */ public void writeToFile(Student student, String filename) throws IOException { try(BufferedWriter writer = new BufferedWriter(new FileWriter(filename))){ String attributes = student.getStudentName() + "\n" + student.getStudentId() + "\n" + student.getStudentRole(); @@ -86,6 +95,11 @@ public class Student { } + /** + * Generates a List of Students from a file + * @param filename Name of the file which is being read + * @return returns List of all Student Data written in that file + */ public static List readFromFile(String filename) { List students = new ArrayList<>(); @@ -107,10 +121,19 @@ public class Student { return students; } + /** + * Assigns a grade to a specific course and records it in the courseGrades map. + * @param course The course for which the grade is being assigned. + * @param grade The grade to be assigned (e.g., "A", "B", "C", etc.). + * + */ public void assignGrade(Course course, String grade) { this.courseGrades.put(course, grade); } + /** + * This Method prints the Grade of a Student to the console + */ public void printGrades() { System.out.println("Grades for Student ID: " + this.studentId + ", Name: " + this.studentName); for (Map.Entry entry : courseGrades.entrySet()) { @@ -120,6 +143,10 @@ public class Student { } } + /** + * This method calculates the total credit points of a Student + * @return the credit points are being returned as an int + */ public int calculateTotalCredits() { int totalCredits = 0; for (Course course : courseGrades.keySet()) {