Question: Appointment Checker Declare a class called Appointment which has Fields: String title int day, month, year Methods: public boolean occursOn(int day, int month, int year)

Appointment Checker

  1. Declare a class called Appointment which has

Fields:

  1. String title
  2. int day, month, year

Methods:

  • public boolean occursOn(int day, int month, int year) - which returns true if the parameters match the appointments day month and year
  • public string toString() - displays the appointment
  • a constructor with a day, month, year and title and a no-args constructor.
  1. Create subclasses of Appointment called SingleAppointment, DailyAppointment, MonthlyAppointment, and YearlyAppointment. Override the occursOn(), toString(), and the constructor methods in each appropriately. For example the constructor for a YearlyAppointment only needs to specify a day, a month and a title. A DailyAppointment only needs a title.
  2. File an array of Appointment type with a variety of the Appointment subclasses. You will have to keep track of how many items are stored in the array with a counter. For example:

final int MAX_APPOINTMENTS=100;

Appointment app[] = new Appointment[MAX_APPOINTMENTS];

int count=0;

app[count++]=new DailyAppoin

tment("Code");

app[count++]=new DailyAppointment("Eat");

app[count++]=new DailyAppointment("Sleep");

app[count++]=new MonthlyAppointment(15,"Get Haircut");

app[count++]=new MonthlyAppointment(1,"Pay Day");

app[count++]=new YearlyAppointment(15,4,"Tax Day");

app[count++]=new YearlyAppointment(1,1,"New Year's Day");

app[count++]=new SingleAppointment(9,5,2020, "Commencement");

app[count++]=new SingleAppointment(16,3,2020, "Start of Spring Break");

app[count++]=new SingleAppointment(18,3,2019, "Start of Spring Break");

  1. Display all the Appointments in the system
  2. Prompt and read from the user for a specific day, month and year
  3. Display all the appointments which match that date.

Sample Run 1: (user input shown in BOLD ITALICS)

Daily: Code

Daily: Eat

Daily: Sleep

Monthly [15] Get Haircut

Monthly [1] Pay Day

Yearly [15/4] Tax Day

Yearly [1/1] New Year's Day

Single [5/9/2020] Commencement

Single [3/16/2020] Start of Spring Break

Single [3/18/2019] Start of Spring Break

Enter a specific day month year separated by spaces. Example: 1 15 2020

1 1 2020

========================================

Daily: Code

Daily: Eat

Daily: Sleep

Monthly [1] Pay Day

Yearly [1/1] New Year's Day

Sample Run 2

Daily: Code

Daily: Eat

Daily: Sleep

Monthly [15] Get Haircut

Monthly [1] Pay Day

Yearly [15/4] Tax Day

Yearly [1/1] New Year's Day

Single [5/9/2020] Commencement

Single [3/16/2020] Start of Spring Break

Single [3/18/2019] Start of Spring Break

Enter a specific day month year separated by spaces. Example: 1 15 2020

9 5 2020

========================================

Daily: Code

Daily: Eat

Daily: Sleep

Single [5/9/2020] Commencement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!