Question
public class Scheduler { private List classes; private List students; public Scheduler() { classes = new ArrayList (); students = new ArrayList (); } public
public class Scheduler { private List } public List public void assignAll() { int m; int count = 0; int rslt = 0; for(Student student: students){ rslt += student.getPreferences().size(); } while(count<=rslt*rslt){ for(Student student: students){ m = 0; for(Course course: student.getPreferences()){ if(m==0) count++; if(m==0 && this.classes.contains(course) && !course.getRoster().contains(student) && course.getRoster().size() * Drops a student from a course. public void drop(Student student, Course course) throws IllegalArgumentException { if(!students.contains(student)) throw new IllegalArgumentException("this student is not in the scheduler"); else if(!classes.contains(course)) { throw new IllegalArgumentException("this course is not in the scheduler"); } else //classes.getRoster().remove(course); course.getRoster().remove(student); student.get().remove(course); } /** * Drops a student from all of their courses. * * @param student * @throws IllegalArgumentException if the student is not known to this scheduler */ public void unenroll(Student student) throws IllegalArgumentException{ if(!students.contains(student)) throw new IllegalArgumentException("this student is not in the scheduler"); else getCourses().removeAll(student.get()); } } public class Student { private String name; private int maxCourses; private List return new ArrayList<>(a); } public List } public class Course { private String courseNumber; private int capacity; private ArrayList if(capacity <=0) { throw new IllegalArgumentException("the capacity is invalid"); } } public int getCapacity() { return capacity; } public String getCourseNumber() { return courseNumber; } public List here are the tests that I failed with: How to fix them? @Test public void testThreeThenUnenrollAndReschedule() { Course d = new Course("DUTCH100", 2); Course e = new Course("ECON100", 3); Student s = new Student("s", 3, Arrays.asList(new Course[] {a, b, c, d, e})); Student t = new Student("t", 4, Arrays.asList(new Course[] {c, a, d, e, b})); Student u = new Student("u", 5, Arrays.asList(new Course[] {b, a, d, c, e})); scheduler.addStudent(s); scheduler.addStudent(t); scheduler.addStudent(u); scheduler.addCourse(a); scheduler.addCourse(b); scheduler.addCourse(c); scheduler.addCourse(d); scheduler.addCourse(e); scheduler.assignAll(); scheduler.unenroll(s); scheduler.assignAll(); checkList(Arrays.asList(new Student[] {s, t, u}), scheduler.getStudents()); checkList(Arrays.asList(new Course[] {a, b, c, d, e}), scheduler.getCourses()); checkList(Arrays.asList(new Student[] {t, s}), a.getRoster()); checkList(Arrays.asList(new Student[] {u, s}), b.getRoster()); assertEquals(Arrays.asList(new Student[] {t}), c.getRoster()); checkList(Arrays.asList(new Student[] {u, t}), d.getRoster()); checkList(Arrays.asList(new Student[] {t, u, s}), e.getRoster()); checkList(Arrays.asList(new Course[] {a, b, e}), s.getSchedule()); checkList(Arrays.asList(new Course[] {c, a, e, d}), t.getSchedule()); checkList(Arrays.asList(new Course[] {b, d, e}), u.getSchedule()); } } @Test public void testUnenrollOne() { Student s = new Student("s", 2, listAB); Student t = new Student("t", 2, listBA); List
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started