Browse Source

Added dropStudentFromCourse feature in Main class

remotes/origin/fdai7887
fdai7887 11 months ago
parent
commit
b5b71bd152
  1. 27
      src/main/java/org/example/Main.java

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

@ -1,6 +1,7 @@
package org.example; package org.example;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Scanner; import java.util.Scanner;
public class Main { public class Main {
@ -57,6 +58,32 @@ public class Main {
break; break;
case 5: case 5:
// Drop Student from Course // Drop Student from Course
System.out.println("Enter Student ID");
String studentID = scanner.next();
System.out.println("Enter Course ID");
String courseIdToDrop = scanner.next();
Student student = administration.findStudentById(studentID);
Course course = administration.findCourseByID(courseIdToDrop);
Map<Course, String> studentCourses = student.getCourseGrades();
if (student != null && course != null) {
if(studentCourses.containsKey(course)){
studentCourses.remove(course);
student.setCourseGrades(studentCourses);
System.out.println("Student has been dropped from the choosen course");
}
else{
System.out.println("Student was not in this course");
}
} else {
if (student == null) System.out.println("Student ID not found.");
if (course == null) System.out.println("Course ID not found.");
}
break; break;
case 6: case 6:
// Create Course // Create Course

Loading…
Cancel
Save