Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE CREATE THE CALENDAR CLASS I HAVE POSTED THIS SEVERAL TIMES AND HAVE GOTTEN NO ANSWER FOR THE CALENDAR CLASS This lab will deal with

PLEASE CREATE THE CALENDAR CLASS I HAVE POSTED THIS SEVERAL TIMES AND HAVE GOTTEN NO ANSWER FOR THE CALENDAR CLASS

This lab will deal with implementing a simulation of a simple calendar with appointments using the concepts of inheritance and subclassing. This is problem P9.1 from the book, with some modifications and additions. We will have an Appointment super class, and three types of appointments that inherit from the super class. Additionally, we will have a Calendar class that will simply be an ArrayList of Appointment objects. You may use BlueJ or Eclipse to complete the lab. (If you want to use some other IDE please talk to me about it). PLEASE COMMENT YOUR CODE. You will have points taken off if you do not comment your code. You can see sample comments in my starter code for how you should comment your code. Keep your code neat.

Tasks: Follow the directions below to complete your lab assignment

For today's lab we will be completing Exercise P9.3 from the book (with modifications/additions).

P9.3 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

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.

Here is some sample output from a working project using the AppointmentDemo.java.txt file posted on UTC Learn. You will need to create additional tests to prove that your project works correctly.

Before removal of appointment

Daily[Brush your teeth. Date: 8/13/2000]

Monthly[Visit grandma. Date: 5/20/2003]

Onetime[Dentist appointment. Date: 11/2/2004]

Onetime[Trick or Treat. Date: 10/31/2004]

Monthly[Dentist appointment. Date: 11/2/2004]

Onetime[Dentist appointment. Date: 11/2/2004]

After removal of 11/2/2004

Monthly[Visit grandma. Date: 5/20/2003]

Onetime[Trick or Treat. Date: 10/31/2004]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

Students also viewed these Databases questions

Question

8. Describe characteristics and advantages of mediation.

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago