Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Implement a superclass Appointment and subclasses Daily, Monthly, and Yearly. An appointment has a description (ie. Go to dentist.) and a date (declaration type

image text in transcribedJAVA

Implement a superclass Appointment and subclasses Daily, Monthly, and Yearly. An appointment has a description (ie. "Go to dentist.") and a date (declaration type is up to you). The Appointment class has a constructor that initializes the instance field, a method occursOn (int year, int month, int day) that returns a boolean by checking whether the appointment occurs on that date, and a toString method that returns the description and date of the appointment. Other methods/variables can be created in the Appointment class if you feel they are required. For example, for a monthly appointment (ie. "Paying the mortgage."), you must check whether the day matches (not the month and the year at or over). Have the Daily class implement the Comparable interface such that the compareTo method will determine which Daily object occurs first by returning either a negative (if calling object is before passing object), positive (if calling object is after passing object), or 0 (if their on the same day). Override the super class toString in each subclass by adding if the appointment is monthly, yearly, or daily. Write a driver program called AppointmentBook and have the user fill an array (or ArrayList) of six or more Appointment objects with a mixture of appointments (at least 2 for each type). Have the user then enter a date and print out the descriptions of all appointments that occur on that date. Have the AppointmentBook class check to see that compareTo works appropriately for Daily objects

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago