Answered step by step
Verified Expert Solution
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
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 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 objectsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started