package scheduler;
import java.util.List;
public class Scheduler {
/**
* Instantiates a new, empty scheduler.
*/
public Scheduler() {
}
/**
* Adds a course to the scheduler.
*
* @param course the course to be added
*/
public void addCourse(Course course) {
}
/**
* Returns the list of courses that this scheduler knows about.
*
* This returned object does not share state with the internal state of the Scheduler.
*
* @return the list of courses
*/
public List<Course> getCourses() {
return null;
}
/**
* Adds a student to the scheduler.
*
* @param student the student to add
*/
public void addStudent(Student student) {
}
/**
* Returns a list of the students this scheduler knows about.
*
* This returned object does not share state with the internal state of the Scheduler.
* @return
*/
public List<Student> getStudents() {
return null;
}
/**
* Assigns all students to courses in the following manner:
*
* For a given student, check their list of preferred courses. Add them to the course that:
* - exists in the scheduler's list of courses
* - the student most prefers (that is, comes first in their preference list)
* - the student is not not already enrolled in
* - and is not full (in other words, at capacity)
* Adds courses to the *end* of the student's current list of classes. Adds students to
* the *end* of the course's roster.
*
* Repeat this process for each student, one-by-one; each student will now have one course,
* usually (but not always) their most preferred course.
*
* Then repeat this whole process (adding one course per student, when possible, proceeding
* round-robin among students), until there is nothing left to do: Students might
* all be at their maximum number of courses, or there may be no available seats in courses
* that students want.
*/
public void assignAll() {
}
/**
* Drops a student from a course.
*
* @param student
* @param course
* @throws IllegalArgumentException if either the student or the course are not known to this scheduler
*/
public void drop(Student student, Course course) throws IllegalArgumentException {
}
/**
* 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{
}
}
---------------------------------------------------------------------
package scheduler;
import java.util.List;
/**
* A class representing a student.
*
* @author liberato
*
*/
public class Student {
/**
*
* Instantiates a new Student object. The student's maximum course load must be greater
* than zero, and the preferences list must contain at least one course.
*
* The preference list is copied into this Student object.
*
* @param name the student's name
* @param maxCourses the maximum number of courses that can be on this student's schedule
* @param preferences the student's ordered list of preferred courses
* @throws IllegalArgumentException thrown if the maxCourses or preferences are invalid
*/
public Student(String name, int maxCourses, List<Course> preferences) throws IllegalArgumentException {
}
/**
*
* @return the student's name
*/
public String getName() {
return null;
}
/**
*
* @return the student's max course load
*/
public int getMaxCourses() {
return -1;
}
/**
* Returns the student's list of course preferences, ordered from most- to least-desired.
*
* This returned object does not share state with the internal state of the Student.
*
* @return the student's preference list
*/
public List<Course> getPreferences() {
return null;
}
/**
* Returns the student's current schedule.
*
* This returned object does not share state with the internal state of the Student.
*
* @return the student's schedule
*/
public List<Course> getSchedule() {
return null;
}
}
---------------------------------------------------------------------------
package scheduler;
import java.util.List;
/**
* A class representing a Course.
*
* @author liberato
*
*/
public class Course {
/**
* Instantiates a new Course object. The course number must be non-empty, and the
* capacity must be greater than zero.
* @param courseNumber a course number, like "COMPSCI190D"
* @param capacity the maximum number of students that can be in the class
* @throws IllegalArgumentException thrown if the courseNumber or capacity are invalid
*/
public Course(String courseNumber, int capacity) throws IllegalArgumentException {
}
/**
*
* @return the capacity of the course
*/
public int getCapacity() {
return -1;
}
/**
*
* @return the course number
*/
public String getCourseNumber() {
return null;
}
/**
* Returns the list of students enrolled in the course.
*
* This returned object does not share state with the internal state of the Course.
*
* @return the list of students currently in the course
*/
public List<Student> getRoster() {
return null;
}
}
Course.java
import java.util.ArrayList;
import java.util.List;
public class Course {
/**
* Instantiates a new Course object. The course number
must be non-empty, and the
* capacity must be greater than zero.
* @param courseNumber a course number, like
"COMPSCI190D"
* @param capacity the maximum
number of students that can be in the class
* @throws IllegalArgumentException thrown if the
courseNumber or capacity are invalid
*/
private String courseNumber;
private int capacity;
private List<Student> roster;
public Course(String courseNumber, int capacity)
throws IllegalArgumentException {
if (courseNumber.isEmpty() == true
|| capacity <= 0) {
throw new
IllegalArgumentException();
}
this.courseNumber =
courseNumber;
this.capacity = capacity;
this.roster = new
ArrayList<Student>();
}
/**
*
* @return the capacity of the course
*/
public int getCapacity() {
return capacity;
}
/**
*
* @return the course number
*/
public String getCourseNumber() {
return courseNumber;
}
/**
* Returns the list of students enrolled in the
course.
*
* This returned object does not share state with the
internal state of the Course.
*
* @return the list of students currently in the
course
*/
public List<Student> getRoster() {
List<Student> listed = new
ArrayList<Student>(roster);
return listed;
}
public void enroll(Student name) {
roster.add(name);
}
public void kickStudent(Student name) {
roster.remove(name);
}
}
Scheduler.java
import java.util.ArrayList;
import java.util.List;
public class Scheduler {
private List<Course> listOfCourses;
private List<Student> listOfStudents;
/**
* Instantiates a new, empty scheduler.
*/
public Scheduler() {
listOfCourses = new
ArrayList<Course>();
listOfStudents = new
ArrayList<Student>();
}
/**
* Adds a course to the scheduler.
*
* @param course the course to be added
*/
public void addCourse(Course course) {
listOfCourses.add(course);
}
/**
* Returns the list of courses that this scheduler
knows about.
*
* This returned object does not share state with the
internal state of the Scheduler.
*
* @return the list of courses
*/
public List<Course> getCourses() {
List<Course> courseList = new
ArrayList<Course>(listOfCourses);
return courseList;
}
/**
* Adds a student to the scheduler.
*
* @param student the student to add
*/
public void addStudent(Student student) {
listOfStudents.add(student);
}
/**
* Returns a list of the students this scheduler knows
about.
*
* This returned object does not share state with the
internal state of the Scheduler.
* @return
*/
public List<Student> getStudents()
{
List<Student> studentList =
new ArrayList<Student>(listOfStudents);
return studentList;
}
/**
* Assigns all students to courses in the following
manner:
*
* For a given student, check their list of preferred
courses. Add them to the course that:
* - exists in the scheduler's list of
courses
* - the student most prefers (that is,
comes first in their preference list)
* - the student is not not already
enrolled in
* - and is not full (in other words, at
capacity)
* Adds courses to the *end* of the student's current
list of classes. Adds students to
* the *end* of the course's roster.
*
* Repeat this process for each student, one-by-one;
each student will now have one course,
* usually (but not always) their most preferred
course.
*
* Then repeat this whole process (adding one course
per student, when possible, proceeding
* round-robin among students), until there is nothing
left to do: Students might
* all be at their maximum number of courses, or there
may be no available seats in courses
* that students want.
*/
public void assignAll() {
Student johnOrJaneDoe;
Course desiredCourse;
Course backUpChoice;
int times = 0;
for(int i = 0; i <
listOfStudents.size(); i++) {
if(listOfStudents.get(i).getPreferences().size() > times)
{
times =
listOfStudents.get(i).getPreferences().size();
}
}
while(true) {
for(int i = 0; i
< times; i++) {
for(int st = 0; st < listOfStudents.size();
st++) {
johnOrJaneDoe =
listOfStudents.get(st);
desiredCourse =
johnOrJaneDoe.getPreferences().get(i);
if(johnOrJaneDoe.getMaxCourses() >
johnOrJaneDoe.getSchedule().size()) {
if(listOfCourses.contains(desiredCourse)) {
if(desiredCourse.getRoster().contains(johnOrJaneDoe) == false)
{
if(desiredCourse.getRoster().size() <
desiredCourse.getCapacity()) {
johnOrJaneDoe.addClass(desiredCourse);
desiredCourse.enroll(johnOrJaneDoe);
}
else {
for(int
rip = i; rip < johnOrJaneDoe.getPreferences().size(); rip++)
{
backUpChoice =
johnOrJaneDoe.getPreferences().get(rip);
if(backUpChoice.getRoster().size() <
backUpChoice.getCapacity()) {
johnOrJaneDoe.addClass(backUpChoice);
backUpChoice.enroll(johnOrJaneDoe);
break;
}
}
}
}
}
}
}
}
break;
}
}
/**
* Drops a student from a course.
*
* @param student
* @param course
* @throws IllegalArgumentException if either the
student or the course are not known to this scheduler
*/
public void drop(Student student, Course course)
throws IllegalArgumentException {
if(listOfStudents.contains(student)
== false || listOfCourses.contains(course) == false) {
throw new
IllegalArgumentException();
}
student.dropClass(course);
course.kickStudent(student);
}
/**
* 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(listOfStudents.contains(student)
== false) {
throw new
IllegalArgumentException();
}
student.useless();
for(int i = 0; i <
listOfCourses.size(); i++) {
if(listOfCourses.get(i).getRoster().contains(student)) {
listOfCourses.get(i).kickStudent(student);
}
}
}
}
Student.java
import java.util.ArrayList;
import java.util.List;
public class Student {
/**
*
* Instantiates a new Student object. The student's
maximum course load must be greater
* than zero, and the preferences list must contain at
least one course.
*
* The preference list is copied into this Student
object.
*
* @param
name the student's
name
* @param maxCourses the maximum number of courses that
can be on this student's schedule
* @param preferences the student's ordered list of
preferred courses
* @throws IllegalArgumentException thrown if the
maxCourses or preferences are invalid
*/
private String name;
private int maxCourses;
private List<Course> preferences;
private List<Course> schedule;
private List<Course> timeTable;
public Student(String name, int maxCourses,
List<Course> preferences) throws IllegalArgumentException
{
if(name.isEmpty() == true ||
maxCourses <= 0 || preferences.size() < 1) {
throw new
IllegalArgumentException();
}
this.name = name;
this.maxCourses = maxCourses;
this.preferences =
preferences;
this.schedule = new
ArrayList<Course>();
}
/**
*
* @return the student's name
*/
public String getName() {
return name;
}
/**
*
* @return the student's max course load
*/
public int getMaxCourses() {
return maxCourses;
}
/**
* Returns the student's list of course preferences,
ordered from most- to least-desired.
*
* This returned object does not share state with the
internal state of the Student.
*
* @return the student's preference list
*/
public List<Course> getPreferences() {
return preferences;
}
/**
* Returns the student's current schedule.
*
* This returned object does not share state with the
internal state of the Student.
*
* @return the student's schedule
*/
public List<Course> getSchedule() {
timeTable = new
ArrayList<Course>(schedule);
return timeTable;
}
public void addClass(Course courseName) {
schedule.add(courseName);
}
public void dropClass(Course courseName) {
schedule.remove(courseName);
}
public void useless() {
schedule.clear();
}
}
package scheduler; import java.util.List; public class Scheduler { /** * Instantiates a new, empty scheduler. */...
DO NOT COPY AND PASTED!!!!!!!!!!!!! IF YOU DO NOT HOW TO DO IT, JUST DO NOT ANSWER MY QUESTIONS package scheduler; import java.util.List; public class Scheduler { /** * Instantiates a new, empty scheduler. */ public Scheduler() { } /** * Adds a course to the scheduler. * * @param course the course to be added */ public void addCourse(Course course) { } /** * Returns the list of courses that this scheduler knows about. * * This returned object...
public class Scheduler { private List<Course> classes; private List<Student> students; public Scheduler() { classes = new ArrayList<Course>(); students = new ArrayList<Student>(); } public void addCourse(Course course) { this.classes.add(course); } public List<Course> getCourses() { List<Course> newCList=new ArrayList<>(); for(int i=0;i<classes.size();i++){ newCList.add(classes.get(i)); } return newCList; } public void addStudent(Student student) { this.students.add(student); } ...
How to complete this methods: import java.io.FileInputStream; import java.io.FileNotFoundException; import java.time.LocalDate; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; /** * Utility class that deals with all the other classes. * * @author EECS2030 Summer 2019 * */ public final class Registrar { public static final String COURSES_FILE = "Courses.csv"; public static final String STUDENTS_FILE = "Students.csv"; public static final String PATH = System.getProperty("java.class.path"); /** * Hash table to store the list of students using their...
package model; import java.util.Iterator; /** * This class implements interface PriorityList<E> to represent a generic * collection to store elements where indexes represent priorities and the * priorities can change in several ways. * * This collection class uses an Object[] data structure to store elements. * * @param <E> The type of all elements stored in this collection */ // You will have an error until you have have all methods // specified in interface PriorityList included inside this...
I need some help fixing this error. I completed the code, just modify it so the error is gone. I had to remove the imports and parts of the test to fit everything public class Scheduler { private List listOfCourses; private List listOfStudents; public Scheduler() { listOfCourses = new ArrayList(); listOfStudents = new ArrayList(); } public void addCourse(Course course) { listOfCourses.add(course); } public List getCourses() { List courseList =...
ANNOTATE BRIEFLY LINE BY LINE THE FOLLOWING CODE: package shop.data; import junit.framework.Assert; import junit.framework.TestCase; public class DataTEST extends TestCase { public DataTEST(String name) { super(name); } public void testConstructorAndAttributes() { String title1 = "XX"; String director1 = "XY"; String title2 = " XX "; String director2 = " XY "; int year = 2002; Video v1 = Data.newVideo(title1, year, director1); Assert.assertSame(title1, v1.title()); Assert.assertEquals(year, v1.year()); Assert.assertSame(director1, v1.director()); Video v2 = Data.newVideo(title2, year, director2); Assert.assertEquals(title1, v2.title()); Assert.assertEquals(director1, v2.director()); } public void testConstructorExceptionYear()...
/** * */ package groceries; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class ShoppingList { /** * @param args */ public static void main(String[] args) { List groceryList = new ArrayList<>(); groceryList.add("rice"); groceryList.add("chicken"); groceryList.add("cumin"); groceryList.add("tomato"); groceryList.add("cilantro"); groceryList.add("lime juice"); groceryList.add("peppers"); groceryList.remove("cilantro"); for (int i = 0; i if (groceryList.get(i).equals("peppers")) {...
How to complete these methods: /** * Returns a reference to the course with title equals to the argument. This * method searches in the courses stored in the HashMap {@code courses} to find * the course whose title equals to the argument {@code title}. If the course is * not found, {@code null} is returned. * * @param title the title of the course * @return a reference to the course, or {@code null} if the course is not ...
Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...
CS HELP Use sets to solve this problem package log; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class LogParser { /** * Returns a list of SuspectEntries corresponding to the CSV data supplied by the given Reader. * * The data contains one or more lines of the format: * * Marc,413-545-3061,1234567890 * * representing a name, phone number, and passport number. * * @param r an open Reader object * @return a list of SuspectEntries...