Browse Source

refactoring: encapsulated the input handling related with case 7

remotes/origin/fdai7887
fdai7600 11 months ago
parent
commit
110c8d0ded
  1. 10
      src/main/java/org/example/Administration.java
  2. 9
      src/main/java/org/example/Main.java

10
src/main/java/org/example/Administration.java

@ -586,6 +586,16 @@ public class Administration {
System.out.println("Student with ID " + studentId + " not found.");
}
}
public void deleteCourseWithInput(Scanner scanner) {
System.out.print("Enter the Course ID of the course you wish to delete: ");
String courseIDToDelete = scanner.next();
boolean isDeleted = deleteCourse(courseIDToDelete);
if (isDeleted) {
System.out.println("Course with ID " + courseIDToDelete + " has been successfully deleted.");
} else {
System.out.println("Course with ID " + courseIDToDelete + " not found.");
}
}
}

9
src/main/java/org/example/Main.java

@ -74,14 +74,7 @@ public class Main {
break;
case 7:
// Delete Course
System.out.println("Enter the Course ID of the course you wish to delete:");
String courseIDToDelete = scanner.next();
boolean isDeleted = administration.deleteCourse(courseIDToDelete);
if (isDeleted) {
System.out.println("Course with ID " + courseIDToDelete + " has been successfully deleted.");
} else {
System.out.println("Course with ID " + courseIDToDelete + " not found.");
}
administration.deleteCourseWithInput(scanner);
break;
case 8:
administration.viewCourses();

Loading…
Cancel
Save