Update src/main/java/Main.java
This commit is contained in:
+28
-4
@@ -70,7 +70,12 @@ public class Main {
|
|||||||
boolean success;
|
boolean success;
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
//TODO
|
success = school.registerStudent(username, password);
|
||||||
|
if (success) {
|
||||||
|
System.out.println(" Student registered successfully!");
|
||||||
|
} else {
|
||||||
|
System.out.println(" Username already exists!");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
success = school.registerTeacher(username, password);
|
success = school.registerTeacher(username, password);
|
||||||
@@ -103,7 +108,12 @@ public class Main {
|
|||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 1:
|
case 1:
|
||||||
//TODO
|
Student student = school.loginStudent(username, password);
|
||||||
|
if (student != null) {
|
||||||
|
studentMenu(student);
|
||||||
|
} else {
|
||||||
|
System.out.println(" Invalid username or password!");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Teacher teacher = school.loginTeacher(username, password);
|
Teacher teacher = school.loginTeacher(username, password);
|
||||||
@@ -141,7 +151,7 @@ public class Main {
|
|||||||
enrollInCourse(student);
|
enrollInCourse(student);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
//System.out.print(student.getMyCoursesDisplay());
|
System.out.print(student.getMyCoursesDisplay());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
System.out.println(" Goodbye, " + student.getUsername() + "!");
|
System.out.println(" Goodbye, " + student.getUsername() + "!");
|
||||||
@@ -153,7 +163,21 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void enrollInCourse(Student student) {
|
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 ====================
|
// ==================== TEACHER MENU ====================
|
||||||
|
|||||||
Reference in New Issue
Block a user