Question: Create an abstract class Appointment that represents an event on a calendar. The Appointment class will have four instance variables: An instance variable called year
Create an abstract class Appointment that represents an event on a calendar. The Appointment class will have four instance variables: An instance variable called year which will be of type int An instance variable called month which will be of type int An instance variable called day which will be of type int An instance variable called description which will be of type String The Appointment class must also implement the following methods: A getter and setter for each of the four instance variables An abstract method named occursOn which returns a boolean and takes three parameters of type int: aYear, aMonth, aDay Overrides the toString method from the Object superclass which returns the String: "Appointment: aDescription On Date: 1/1/1969" where, aDescription is the value stored in the description instance variable and 1/1/1969 are the values stored in the month, day, and year instance variables respectively. Overrides the equals method from the Object superclass which takes a single parameter of type Object and returns true if the given objects is an Appointment object and its year, month, and day instance variables are equal to the current objects instance variables. If the given parameter is null, equals should return false. Create a class Onetime which subclasses the Appointment class. The Onetime class will define no new instance variables. Write a parameterized constructor which takes three parameters of type int: aYear, aMonth, aDay. The parameterized constructor sets the year, month, and day instance variables defined in the Appointment class to the values passed as parameters. The parameterized constructor should set the description instance variable to an empty String. ("") The Onetime class must also implement the following methods: It must implement the abstract method occursOn defined in the Appointment class. occuresOn should return true if the given parameters match the year, month, and day instance variables for the object. Otherwise it should return false. Create a class Yearly which subclasses the Appointment class. The Yearly class will define no new instance variables. Write a parameterized constructor which takes two parameters of type int: aMonth and aDay. The parameterized constructor sets the month and day instance variables defined in the Appointment class to the values passed as parameters. The parameterized constructor should set the description instance variable to an empty String. ("") The Yearly class must also implement the following methods: It must implement the abstract method occursOn defined in the Appointment class. occuresOn should return true if the given parameters match the month and day instance variables for the object. (We can ignore the aYear parameter because this event repeats yearly so every value is correct) Otherwise it should return false. Overrides the toString method from the Object superclass which returns the String: "Appointment: aDescription Every Year On 1/1" where, aDescription is the value stored in the description instance variable and 1/1 are the values stored in the month and day instance variables respectively. Create a class Monthly which subclasses the Appointment class. The Monthly class will define no new instance variables. Write a parameterized constructor which takes one parameter of type int: aDay. The parameterized constructor sets the day instance variable defined in the Appointment class to the value passed as a parameter. The parameterized constructor should set the description instance variable to an empty String. ("") The Monthly class must also implement the following methods: It must implement the abstract method occursOn defined in the Appointment class. occuresOn should return true if the given parameters match the day instance variable for the object. (We can ignore the aYear and aMonth parameters because this event repeats monthly so every value is correct) Otherwise it should return false. Overrides the toString method from the Object superclass which returns the String: "Appointment: aDescription Every Month On 1" where, aDescription is the value stored in the description instance variable and 1 is the values stored in the day instance variable respectively.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
