diff --git a/src/main/java/org/example/Administration.java b/src/main/java/org/example/Administration.java index bbd7f83..e3fe0ee 100644 --- a/src/main/java/org/example/Administration.java +++ b/src/main/java/org/example/Administration.java @@ -407,6 +407,17 @@ public class Administration { } + + public void createCourse(String courseName, String courseID, int credits) { + // Check if a course with the given ID already exists + if (findCourseByID(courseID) != null) { + System.out.println("A course with ID " + courseID + " already exists."); + } else { + Course newCourse = new Course(courseName, courseID, credits); + courses.add(newCourse); + System.out.println("Course " + courseName + " (" + courseID + ") created successfully."); + } + } } diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index f41f76d..f914439 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -38,10 +38,10 @@ public class Main { switch (choice) { case 1: // Register User + administration.registerUser(); break; case 2: - // Enroll Student in Course - break; + break; case 3: // Enroll Prof to Course break; @@ -53,6 +53,13 @@ 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); break; case 7: // Delete Course