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
- Declare a class called Appointment which has
Fields:
- String title
- 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.
- 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.
- 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");
- Display all the Appointments in the system
- Prompt and read from the user for a specific day, month and year
- 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
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