1 Calendar

1.1 Description

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.

1.2 The Calendar interface

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();

1.3 Appointment objects

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.)

1.4 Example

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);

1.5 Report

You must write a short report (please try to keep it under 2 pages). The report should include the following:

  • A high level overview of your implementation (one paragraph, or bullet points.)
  • For each data structure used, state what you used it for and why you chose it (one paragraph each, or bullet points.)
  • For each of the five methods declared in the Calendar interface, state the running time of your implementation in big-Oh notation, and give a brief argument justifying that this is correct.
  • Describe how you tested your code. List the test cases you wrote, stating briefly the purpose of each test.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.