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."); 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; break;
case 7: case 7:
// Delete Course // 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; break;
case 8: case 8:
administration.viewCourses(); administration.viewCourses();

Loading…
Cancel
Save