Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/org/example/Administration.java
remotes/origin/fdai7887
fdai7600 11 months ago
parent
commit
0b69f68241
  1. 69
      src/main/java/org/example/Administration.java
  2. 5
      src/main/java/org/example/Main.java

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

@ -407,6 +407,75 @@ public class Administration {
}
public void enrollProfInCourse(){
System.out.println("Please enter Professor ID");
String profID = scanner.next();
while(this.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(this.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 = this.findProfessorById(profID);
Course course = this.findCourseByID(courseID);
List<Course> courseList = prof.getCoursesTaught();
courseList.add(course);
prof.setCoursesTaught(courseList);
System.out.println("Professor enrolled successfully");
}
public void dropProfFromCourse(){
System.out.println("Please enter Professor ID");
String profID = scanner.next();
while(this.findProfessorById(profID) == null){
System.out.println("This Professor does not exist");
System.out.println("Please enter a new Professor ID");
profID = scanner.next();
}
Professor prof = this.findProfessorById(profID);
List<Course> courseList = prof.getCoursesTaught();
System.out.println("Please enter Course ID");
String courseID = scanner.next();
boolean isDeleted = false;
while(!isDeleted) {
//Checks if course exists
while(this.findCourseByID(courseID) == null ){
System.out.println("This Course does not exist");
System.out.println("Please enter a new Course ID");
courseID = scanner.next();
}
//Checks if Prof is enrolled in course
for (Course course : courseList) {
if (course.getCourseID().equals(courseID)) {
courseList.remove(this.findCourseByID(courseID));
prof.setCoursesTaught(courseList);
System.out.println("Course deleted successfully");
isDeleted = true;
break;
}
System.out.println("The Professor is not enrolled in this course");
System.out.println("Please enter a new Course ID");
courseID = scanner.next();
}
}
}
public void createCourse(String courseName, String courseID, int credits) {
// Check if a course with the given ID already exists

5
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,9 +46,12 @@ public class Main {
break;
case 3:
// Enroll Prof to Course
administration.enrollProfInCourse();
break;
case 4:
// Drop Prof from Course
administration.dropProfFromCourse();
break;
case 5:
// Drop Student from Course

Loading…
Cancel
Save