Instructions: Appointment Checker – HW 04 1. Declare a class called Appointment which has Fields: 1. · String title · int day, month, year Methods: · public boolean occursOn(int day, int month, int...

1 answer below »
uploaded in a word document


Instructions: Appointment Checker – HW 04   1. Declare a class called Appointment which has Fields: 1. · String title · int day, month, year Methods: · public boolean occursOn(int day, int month, int year)  - which returns true if the parameters match the appointment’s day month and year · public string toString()  - displays the appointment · a constructor with a day, month, year and title and a no-args constructor. 2. 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. 3. 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"); 4. Display all the Appointments in the system 5. Prompt and read from  the user for a specific day, month and year 6. 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
Answered Same DaySep 07, 2021

Answer To: Instructions: Appointment Checker – HW 04 1. Declare a class called Appointment which has Fields: 1....

Sayed Shad Ahmad answered on Sep 08 2021
155 Votes
Solution/Java Files/Appointment.java
Solution/Java Files/Appointment.java
//Class Appointment
public class Appointment 
{
    //Declaring data members of Appointment class to store title, day, month & year

    private String title;
    private int day;
    private int month;
    private int year;

    //Default Constructor for Appointment class
    public Appointment()
    {
        //Initializing the data members with default values
        this.title = "";
        this.day = 0;
        this.month = 0;
        this.year = 0;
    }
    //Parameterized Constructor for Appointment class
    public Appointment(String title, int day, int month, int year) 
    {
        //Initializing the data members with values received as arguments
        this.title = title;
        this.day = day;
        this.month = month;
        this.year = year;
    }

    //Method to check whether the appointment occurs on the day, month & year received as arguments
    public boolean occursOn(int day, int month, int year)
    {
        //Checking whether day, month & year of appointment matches the day, month & year received as arguments or not
        if(this.day == day && this.month == month && this.year == year)
            //Returning true when day, month & year matches
            return true;
        else
            //Returning true when day, month & year doesn't match
            return false;
    }
    //Overridden method to display the Appointment
    @Override
    public String toString() 
    {
        //Returning the day, month, year & title of appointment
        return "[" + this.month + "/" + this.day + "/" + this.year + "] " + this.title;
    }
    //Getter method to get title of Appointment
    public String getTitle()
    {
        return title;
    }
    //Getter method to get Day of Appointment
    public int getDay()
    {
        return day;
    }
    //Getter method to get Month of Appointment
    public int getMonth()
    {
        return month;
    }
}
Solution/Java Files/DailyAppointment.java
Solution/Java...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here