Browse Source

refactoring: encapsulated the input handling related with case 6

remotes/origin/fdai7887
fdai7600 11 months ago
parent
commit
b0fea42a7c
  1. 12
      src/main/java/org/example/Administration.java
  2. 8
      src/main/java/org/example/Main.java

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

@ -597,6 +597,18 @@ public class Administration {
}
}
public void createCourseWithInput(Scanner scanner) {
System.out.print("Enter Course Name: ");
String courseName = scanner.next();
System.out.print("Enter Course ID: ");
String courseID = scanner.next();
System.out.print("Enter Credits: ");
int credits = scanner.nextInt();
Course newCourse = new Course(courseName, courseID, credits);
addCourse(newCourse);
System.out.println("Course created successfully.");
}
}

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

@ -64,13 +64,7 @@ public class Main {
break;
case 6:
// Create Course
System.out.println("Enter Course Name:");
String courseName = scanner.next();
System.out.println("Enter Course ID:");
String courseID = scanner.next();
System.out.println("Enter Credits:");
int credits = scanner.nextInt();
administration.createCourse(courseName, courseID, credits);
administration.createCourseWithInput(scanner);
break;
case 7:
// Delete Course

Loading…
Cancel
Save