Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 9.3 Implement a superclass Appointment and subclasses OneTime, Daily, and Monthly. An appointment has a description (for example, see the dentist) and a date.

Homework 9.3 Implement a superclass Appointment and subclasses OneTime, Daily, and Monthly. An appointment has a description (for example, see the dentist) and a 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. Give the user the option to add new appointments or to search a date for appointments.

More specifically:

1. Appointment the superclass

a. Has 4 instance variables

b. Has a constructor with 4 parameters

c. Has methods occursOn, getDay, getMonth, getYear, and toString.

2. OneTime a subclass

a. Has a constructor that refers to the superclass

3. Daily a subclass

a. Has a constructor that refers to the superclass

b. Overrides the method occursOn

i. Make sure the date in question is not before the start date of a daily appointment

4. Monthly a subclass

a. Has a constructor that refers to the superclass

b. Overrides the method occursOn

i. Make sure the date in question is not before the start date of a month appointment

ii. A monthly appointment will occur on the same numeric day each month (i.e. the 5th)

5. AppointmentRunner the class that runs the program

a. In the main method,

i. Initialize an ArrayList of appointments and enter any 4 appointments of any type.

ii. Use a loop to give options to the user (add appointment, search by date, exit).

b. In a static method addAppointment,

i. Receive user input for day, month, year, description, and frequency of appointment.

ii. Depending on frequency, a different constructor should be called.

c. In a static method searchAppointments,

i. Receive user input for day, month, and year in question.

ii. Use an enhanced for loop and the occursOn method to look for and print all appointments.

iii. If no appointments are found, inform the user.

Things you can assume:

1. The user will always enter an integer.

2. The integer will always be in the appropriate range (day/month/year numbers, menu selections, etc.).

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

Students also viewed these Databases questions