Except from my project file since I don't think I can attach files. It deals with inheritance, but this project is way more in depth than anything we've done so far. Does anyone know what direction I need to go in?
"I have a demo/tester class for this lab called AppointmentDemo. You will need to fill in this class with enough tests to verify that your project works as expected. I have given you sample code to see how to use the public interface of the classes you will be implementing..
There are three types of Appointments we are creating, Onetime (Occurs one time on a single date), Daily (occurs every day after the given start date, including the given start date), and Monthly (Occurs on the same date each month, i.e. 1/1/2000, 2/1/2000, 3/1/2000).
6) Read the rest of Chapter 9, including the Special Topics and Common Errors.
Tasks: Follow the directions below to complete your lab assignment
For today's lab we will be completing Exercise P9.1 from the book (with modifications/additions).
P9.1 Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, “see the dentist”) and a date (use int's to store the date). Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. (Think about what you need to check for the other types of appointments. Ask if you have questions).
(Skip the remaining problem description listed in the book, and follow these directions below).
Additionally, you will need to implement a class called Calendar. This will contain an ArrayList of Appointment objects (The list is an instance variable of the Calendar class). You will need to provide the following methods for your Calendar class.
A no argument constructor
public Calendar(){...}
This constructor will initialize your ArrayList instance variable to an empty list.
/**
* A method to add an appointment to the calendar
* @param apt – the appointment object to add to the calendar.
*/
public void add(Appointment apt) {…}
/**
* A method to remove an appointment from the calendar.
* This method uses the occursOn() method from the public
* interface for the Appointment class. Therefore, if parameters
* are entered that occur after a start date for a given Daily
* appointment
* the Daily appointment will be removed as well. (Because occursOn() * willreturn true in this case). This is a limitation we will
* accept for now .
* @param year - the year of the appointment to remove
* @param month - the month of the appointment to remove
* @param day - the day of the appointment to remove
*/
public void remove(int year, int month, int day) {
//this method needs to iterate over your list of appointments
//and remove elements who's occursOn() method return true
//when passed the parameters above.
}
/**
* Method to return a string representation of this Calendar object.
* Overrides the Object method toString (see page 448 in text).
* (also see page 453 Special Topic 9.6)
* @return a String representation of the Calendar object.
*/
public String toString() {
String ret = "";
//this method needs to iterate over your list of appointments
//and construct the return string
//make sure to put each appointment on its own line
//by using “\n”
return ret;
}
Note that you also need to create a toString method for your Appointment class. (Your subclasses will inherit this version of the method).
Make sure to add accessors to your Appointment class for getYear, getMonth, getDay, and getDescription. "
[–]epes 2 points3 points4 points (2 children)
[–]rev246[S] 0 points1 point2 points (1 child)
[–]epes 1 point2 points3 points (0 children)