From 6fee2e981a75a44dcccfe32a181696c0f078130a Mon Sep 17 00:00:00 2001 From: Partow Roshani Date: Sun, 3 May 2026 14:39:27 +0000 Subject: [PATCH] Update src/main/java/Main.java --- src/main/java/Main.java | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index edfa2f5..c150f76 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -70,7 +70,12 @@ public class Main { boolean success; switch (choice) { case 1: - //TODO + success = school.registerStudent(username, password); + if (success) { + System.out.println(" Student registered successfully!"); + } else { + System.out.println(" Username already exists!"); + } break; case 2: success = school.registerTeacher(username, password); @@ -103,7 +108,12 @@ public class Main { switch (choice) { case 1: - //TODO + Student student = school.loginStudent(username, password); + if (student != null) { + studentMenu(student); + } else { + System.out.println(" Invalid username or password!"); + } break; case 2: Teacher teacher = school.loginTeacher(username, password); @@ -141,7 +151,7 @@ public class Main { enrollInCourse(student); break; case 3: - //System.out.print(student.getMyCoursesDisplay()); + System.out.print(student.getMyCoursesDisplay()); break; case 4: System.out.println(" Goodbye, " + student.getUsername() + "!"); @@ -153,7 +163,21 @@ public class Main { } private static void enrollInCourse(Student student) { - //TODO + System.out.print(school.getAllCoursesDisplay()); + System.out.print("\nEnter Course ID to enroll: "); + int courseId = getIntInput(); + + Course course = school.findCourseById(courseId); + if (course == null) { + System.out.println(" Course not found! Please enter a valid ID."); + return; + } + + if (student.enrollInCourse(course)) { + System.out.println(" Successfully enrolled in " + course.getName()); + } else { + System.out.println(" You are already enrolled in this course!"); + } } // ==================== TEACHER MENU ====================