Assignment 05: Scheduler

Starter code: scheduler-student.zip

Overview

Common complaints among students are that SPIRE is awful, that setting up schedules is awful, and so on. Turns out, common complaints among registrars are that (name-of-University’s-registration-system) is awful, that setting up schedules is awful, and so on. So maybe you can do better?

In this assignment, you’ll write an automated course scheduler, which given a list of students and courses, does its best to put students into their preferred courses while not exceeding their maximum course load (and not exceeding the capacity of any courses).

We’ve provided a large set of unit tests to help with automated testing, though you might also want to write a class with a main method for interactive testing. The Gradescope autograder includes a few more tests, but they exist primarily to verify you’re not gaming the autograder. If your code can pass the tests we’ve provided, it is likely correct. As before, we’ve disable the timeout code so you can use the debugger, but if your code gets stuck during testing, you might want to uncomment these two lines at the top of each test file:

	@Rule
	public Timeout globalTimeout = Timeout.seconds(10); // 10 seconds

Goals

Downloading and importing the starter code

As in previous assignments, download and decompress the provided archive file containing the starter code. Then import it into Code in the same way; you should end up with a scheduler-student project.

What to do

As usual, look over the files we’ve provided. The Course class describes a course, including its name and maximum capacity. The Student class represents a single student, their maximum course load, and a list of courses the student would like (in order of preference, most-preferred-to-least). The Scheduler class is responsible for maintaining lists of students and courses, and for placing students into courses correctly.

You’ll need to write Course and Student before you tackle Scheduler. Notes:

How can you make this copy? It depends. If your roster is built on the fly from other objects’ state, than the new list you build will automatically be independent. If the roster is a List instance variable, then copy it using the ArrayList’s copy constructor. In other words, by writing something like return new ArrayList<>(this.roster);

Then move on to Scheduler. Some hints:

Take a look at SchedulerTest.testThree() to get a sense of how the scheduler works:

The test checks that the students have the right schedules, and that the courses have the right rosters.

Submitting the assignment

When you have completed the changes to your code, you should export an archive file containing the entire Java project. To do this, follow the same steps as from Assignment 01 to produce a .zip file, and upload it to Gradescope. Note that if you want things to upload faster, you can use an external program to zip only the src/ directory by expanding the project; that’s all this autograder requires.

Remember, you can resubmit the assignment as many times as you want, until the deadline. If it turns out you missed something and your code doesn’t pass 100% of the tests, you can keep working until it does.