From 3744102661584db7487818a901973261f644d488 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Thu, 8 Feb 2024 21:10:44 +0100 Subject: [PATCH] refactoring: follow up on the redundancy on the Menu (element 11-13) --- src/main/java/org/example/Administration.java | 32 ------------------- src/main/java/org/example/Main.java | 9 ++---- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index e613922..dd214cc 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -541,38 +541,6 @@ public class Administration { return false; } - - public void createCourse(String courseName, String courseID, int credits) { - // Check if a course with the given ID already exists - if (findCourseByID(courseID) != null) { - System.out.println("A course with ID " + courseID + " already exists."); - } else { - Course newCourse = new Course(courseName, courseID, credits); - courses.add(newCourse); - System.out.println("Course " + courseName + " (" + courseID + ") created successfully."); - } - } - - public boolean enrollStudentInCourse(String studentId, String courseId) { - Student student = findStudentById(studentId); - Course course = findCourseByID(courseId); - if (student != null && course != null) { - // If the course is not already enrolled - if (!student.getCourseGrades().containsKey(course)) { - student.getCourseGrades().put(course, "Not Graded"); - System.out.println("Student " + studentId + " enrolled in course " + courseId + "."); - return true; - } else { - System.out.println("Student " + studentId + " is already enrolled in course " + courseId + "."); - return false; - } - } else { - if (student == null) System.out.println("Student ID not found."); - if (course == null) System.out.println("Course ID not found."); - return false; - } - } - } diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index 2544299..0bc5252 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -30,10 +30,7 @@ public class Main { System.out.println("8. View Courses"); System.out.println("9. Assign Grade to Student"); System.out.println("10. View Grades from Student"); - System.out.println("11. View User"); - System.out.println("12. Delete User"); - System.out.println("13. View Course List"); - System.out.println("14. Exit (includes saving data in the files)"); + System.out.println("11. Exit (includes saving data in the files)"); System.out.print("Select an option: "); int choice = scanner.nextInt(); @@ -104,10 +101,8 @@ public class Main { case 10: // View Grades from Student break; + case 11: - // Delete User - break; - case 12: // Exit (includes saving data in the files) exit = true; System.out.println("Exiting...");