diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index dd214cc..07f5a16 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -509,6 +509,17 @@ public class Administration { } } + public void enrollStudentInCourseInteractive() { + System.out.println("Enter Student ID:"); + String studentId = scanner.nextLine(); // Use nextLine for consistent input handling + System.out.println("Enter Course ID:"); + String courseId = scanner.nextLine(); + + boolean enrolled = enrollStudentInCourse(studentId, courseId); +// Feedback for failure is handled within the enrollStudentInCourse method + + } + public void viewCourses() { if (courses.isEmpty()) { System.out.println("No courses available."); diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index 0bc5252..c22840f 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -40,11 +40,7 @@ public class Main { administration.registerUser(); break; case 2: // Enroll Student in Course - System.out.println("Enter Student ID:"); - String studentId = scanner.next(); - System.out.println("Enter Course ID:"); - String courseId = scanner.next(); - administration.enrollStudentInCourse(studentId, courseId); + administration.enrollStudentInCourseInteractive(); break; case 3: // Enroll Prof to Course