Browse Source

Added Create course function Administration and implemented in Main

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

11
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.");
}
}
}

11
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

Loading…
Cancel
Save