In this assignment you will write the code for a class Assignment which implements the Calendar interface. The full skeleton code for the assignment is available for download on the resources section of Ed, and is also listed in the appendix.
Objects implementing the Calendar interface allow you to keep track of Appointment objects. The Calendar interface has the following methods:
// Return a list of all appointments at the given location (at any time)
// If there are no such appointments , return an empty list
// Throws IllegalArgumentException if the argument is null
public List< Appointment > getAppointments(String location);
// Return the next appointment at or after the given time (in any location)
// If there is no such appointment , return null
// Throws IllegalArgumentException if the argument is null
public Appointment getNextAppointment(Date when);
// Return the next appointment at or after the given time , at that location
// If there is no such appointment , return null
// Throws IllegalArgumentException if any argument is null
public Appointment getNextAppointment(Date when, String location);
// Create a new appointment in the calendar
// Throws IllegalArgumentException if any argument is null
public void add(String description , Date when, String location);
// Remove an appointment from the calendar
// Throws IllegalArgumentException if the argument is null
public void remove(Appointment appointment);
For all of the methods, if any of the arguments passed to the method are null, then you should throw new IllegalArgumentException();
Each Appointment object has a description (String), a start time (java.util.Date), and a location (String). You may assume that Appointment objects are immutable. That means that once an Appointment has been created, it cannot be modified (but it could be removed.)
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Calendar calendar = new Calendar();
calendar.add("A", df.parse("2016/09/03 09:00:00"), "SIT lab 117");
calendar.add("B", df.parse("2016/09/03 16:00:00"), "SIT lab 117");
calendar.add("C", df.parse("2016/09/03 16:00:00"), "SIT lab 118");
calendar.add("D", df.parse("2016/09/03 18:00:00"), "SIT lab 117");
// This will return a list containing Appointments A, B and D
List< Appointment > example1 = calendar.getAppointments("SIT lab 117");
// This can return either Appointment B, or Appointment C
// It does not matter which one, as they are both correct.
Appointment example2 = calendar.getNextAppointment(df.parse("2016/09/03 13:00:00"));
// This will return Appointment B
Appointment example3 = calendar.getNextAppointment(df.parse("2016/09/03 13:00:00"), "SIT lab 117");
// This would return null
Appointment example4 = calendar.getNextAppointment(df.parse("2020/01/01 13:00:00"));
// This would cause an IllegalArgumentException to be thrown
Appointment example5 = calendar.getNextAppointment(null);
You must write a short report (please try to keep it under 2 pages). The report should include the following: