Browse Source

Implemented enrollProfToCourse function in Main class

remotes/origin/fdai7780
fdai7887 11 months ago
parent
commit
d94f43320d
  1. 23
      src/main/java/org/example/Main.java

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

@ -1,4 +1,6 @@
package org.example;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
@ -44,6 +46,27 @@ public class Main {
break;
case 3:
// Enroll Prof to Course
System.out.println("Please enter Professor ID");
String profID = scanner.next();
while(administration.findProfessorById(profID) == null){
System.out.println("This Professor does not exist");
System.out.println("Please enter a new Professor ID");
profID = scanner.next();
}
System.out.println("Please enter Course ID");
String courseID = scanner.next();
while(administration.findCourseByID(courseID) == null){
System.out.println("This Course does not exist");
System.out.println("Please enter a new Course ID");
courseID = scanner.next();
}
Professor prof = administration.findProfessorById(profID);
Course course = administration.findCourseByID(courseID);
List<Course> courseList = prof.getCoursesTaught();
courseList.add(course);
prof.setCoursesTaught(courseList);
break;
case 4:
// Drop Prof from Course

Loading…
Cancel
Save