Update src/main/java/Main.java

This commit is contained in:
2026-05-03 09:29:49 +00:00
parent 636a3277c6
commit 3618726133
+9 -8
View File
@@ -135,13 +135,13 @@ public class Main {
switch (choice) { switch (choice) {
case 1: case 1:
school.showAllCourses(); System.out.print(school.getAllCoursesDisplay());
break; break;
case 2: case 2:
enrollInCourse(student); enrollInCourse(student);
break; break;
case 3: case 3:
//student.showMyCourses(); //System.out.print(student.getMyCoursesDisplay());
break; break;
case 4: case 4:
System.out.println(" Goodbye, " + student.getUsername() + "!"); System.out.println(" Goodbye, " + student.getUsername() + "!");
@@ -174,13 +174,13 @@ public class Main {
switch (choice) { switch (choice) {
case 1: case 1:
school.showAllCourses(); System.out.print(school.getAllCoursesDisplay());
break; break;
case 2: case 2:
addNewCourseToSystem(teacher); addNewCourseToSystem(teacher);
break; break;
case 3: case 3:
teacher.showMyCourses(); System.out.print(teacher.getMyCoursesDisplay());
break; break;
case 4: case 4:
addCourseToTeacher(teacher); addCourseToTeacher(teacher);
@@ -216,7 +216,7 @@ public class Main {
} }
private static void addCourseToTeacher(Teacher teacher) { private static void addCourseToTeacher(Teacher teacher) {
school.showAllCourses(); System.out.print(school.getAllCoursesDisplay());
System.out.print("\nEnter Course ID to add to your list: "); System.out.print("\nEnter Course ID to add to your list: ");
int courseId = getIntInput(); int courseId = getIntInput();
@@ -234,7 +234,7 @@ public class Main {
} }
private static void removeCourseFromTeacher(Teacher teacher) { private static void removeCourseFromTeacher(Teacher teacher) {
teacher.showMyCourses(); System.out.print(teacher.getMyCoursesDisplay());
if (teacher.getMyCourses().isEmpty()) return; if (teacher.getMyCourses().isEmpty()) return;
System.out.print("\nEnter Course ID to remove from your list: "); System.out.print("\nEnter Course ID to remove from your list: ");
@@ -254,7 +254,7 @@ public class Main {
} }
private static void showStudentsInTeacherCourse(Teacher teacher) { private static void showStudentsInTeacherCourse(Teacher teacher) {
teacher.showMyCourses(); System.out.print(teacher.getMyCoursesDisplay());
if (teacher.getMyCourses().isEmpty()) return; if (teacher.getMyCourses().isEmpty()) return;
System.out.print("\nEnter Course ID to see students: "); System.out.print("\nEnter Course ID to see students: ");
@@ -266,7 +266,8 @@ public class Main {
return; return;
} }
teacher.showStudentsInCourse(course); String result = teacher.getStudentsDisplayForCourse(course);
System.out.println(result);
} }
private static int getIntInput() { private static int getIntInput() {