Homework 2

Learning Objectives

In this homework, you will apply the concepts you learned in class to reinforce your understanding of:

Homework Policy

This is an indiviual homework assignment. Please review Academic Integrity section of the class syllabus for rules on individual homework assignments.

Description

Design and implement an appointment book program. The program must support two types of events that can be recorded in an appointment book. These events are:

Both types of events consist of a contact (the name and telephone number of a person), and the start time of the event. Events always last for one hour. An appointment book is a collection of events. Events can be added to the appointment book and the list of events for a given date can be retrieved. When adding events to the appointment book, we don't want any overlap: if we try to add an event that is in conflictwith the current schedule (has some time overlap), that event should not get added.

We all know that meetings tend to run over time, so if we are scheduling events, we don't want to schedule any event to start exactly when the meeting is scheduled to end. To ensure that we don't schedule any event exactly at meeting end time, we'll give our meetings an extra time buffer at the end. Also, it is a good idea to show up for your appointments a few minutes early, so we want to schedule in a time buffer at the start of our appointments. Here are some examples:

When scheduling extra time at the end of a meeting or at the start of an appointment, we want to give ourselves flexibility to change the time buffers as we want, so don't hard code any values into your classes. Additionally, meetings can have a list of attendees.

Your job is to design the classes that support this functionality. Your classes must work with this Driver. You should also write your own driver that tests out the functionality of your classes in more detail.

Getting started

To help you get started, I put together a UML class diagram of the solution. Your solution must implement all the public methods specified in this diagram exactly as they are specified. Classes must be named exactly as specified in the diagram. You are welcome to add more attributes and methods to your classes. Note, that in this diagram, the Event class is in italics font, which indicates that Event is an abstract class and has two abstract methods (also specified in italics font). The Appointment and Meeting classes extend Event and implement the abstract methods of the Event class. Since Meeting and Appointment classes have different scheduling rules (meetings last longer than scheduled and appointments start time should be earlier than scheduled), you want to account for these rules in the implementation of the abstract methods.

The appointment book class contains a collection of Events (indicated by a "has-a" connection in the UML diagram). Events can be added to the appointment book, if they do not overlap with any existing events (taking into account the meetings that will run late and appointments that start early). Note that addEvent method of the AppointmentBook returns a boolean: true if the event was added and false otherwise. We can set or change the start buffer of an Appintment (the extra time we want to schedule in before the appointment's real start) by calling setStartBuffer(). We can set or change the end buffer of a meeting (the extra time we want to schedule after the meeting, in case it runs overtime) by calling setEndBuffer().


The date and time of each event is represented by GregorianCalendar class. It is a class from the java.util library. To use this class you will need to include import java.util.GregorianCalendar; at the top of each file that uses this class. GregorianCalendar is a convenient way to encapsulate date and time, and provides several methods for adding and subtracting hours and minutes to a given GregorianCalendar object. You will need to look up the details of how to use this class on the Java documentation site. As you browse the documentation, note that GregorianCalendar is itself a subclass of Calendar. Therefore, it inherits all the methods of the Calendar class. To use methods and attributes of the Calendar class, you need to import java.util.Calendar; at the top of each file that uses that class. Here are some useful methods from the documentation site:

Remember to start your solution by stubbing out the required classes and methods. Make sure your stubs compile with the provided Driver. After that, iteratevely fill out the details of each method and expand the Driver to make sure your methods work correctly.

Submitting your solution

Submit your solution to this homework to hw3 directory of your CSCI 2300 git repo. You do not need to submit Driver.java (although it's ok if you do submit it). You will be graded on the quality of the classes you created. Your Driver.java will not be graded.

Grading

Homework 2 is worth 100 points. Here is how your grade will be calculated: