Question: Hi, please help with the following Java question. Please create an abstract Appointment class and Onetime, Daily, and Monthly subclasses. An appointment has a description
Hi, please help with the following Java question.
Please create an abstract Appointment class and Onetime, Daily, and Monthly subclasses. An appointment has a description (e.g., doctors visit) and a date (stored as year, month, and day separately). Include a constructor as well as getters and setters for each attribute.
The Appointment class has an abstract method named occursOn that has three parameters, the year, month, and day and returns whether or not the appointment occurs on the given date.
When an Appointment is printed, its description should be displayed. Include a toString method to reflect this.
For a monthly appointment (i.e., an appointment that occurs every month on the same day), you must check whether the day of the month matches. Appointments occurring in earlier months do not match, but those in upcoming months (on the same day as given by the parameter) do.
For example, if your monthly appointment is on 11/4/18 and your given date for occursOn is 10/4/18, the appointment is not a match. If your given date is 12/1/18, it is still not a match. A different month, but the same day, within the same year or a future year are matches for monthly appointments.
For a daily appointment (i.e., an appointment that occurs every day), you must check whether the appointments date is today or any day in the future. For Onetime appointments (i.e., that only occurs once), you must check whether the dates match exactly.
In a driver, please test your classes using polymorphism. To do this, create an array (or ArrayList) of Appointment objects and fill it with a mixture of different appointment objects, there must be at least 1 of each subclass. Have the user enter a date and print out all appointments that occur on that date.
With the following appointments in an ArrayList in the driver: Take a shower - a daily appointment, scheduled for 10/22/2018 Brush your teeth - a daily appointment, scheduled for 10/31/2018 Call your gran - a monthly appointment, scheduled for 11/4/2018 Doctors appointment - a one time appointment, scheduled for 12/4/2018 Christmas - a one time appointment, scheduled for 12/25/2018 Heres a sample run: (user input in bold): Enter a date (month, day, year) to get a list of appointments that match that date: 12 4 2018 take a shower brush your teeth call your gran doctors appointment Heres another!
Heres another sample run: (user input in bold): Enter a date (month, day, year) to get a list of appointments that match that date: 12 25 2018 take a shower brush your teeth Christmas
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
