Update src/main/java/Main.java

This commit is contained in:
2026-05-03 14:39:27 +00:00
parent 5130cf9069
commit 6fee2e981a
+28 -4
View File
@@ -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 ====================