Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date of an appointment, the month of an appointment, the year of an appointment, and the description of an appointment (e.g., "see the dentist"). In other words, four major instant variables in these classes. Then, write a method occcursOn(year, month, day) that checks whether the appointment occurs on that date. Ensure to have a test program to test your classes. In your test program, you should create a list of appointments using the concept of polymorphism as your appointment pool. In other words, creating multiple objects using your subclasses of Onetime, Daily, and Monthly. Once you have those appointments available, allow the user to input day, month, and year to check whether the day of the month matches and print out the information of that matched appointment. For example, for a monthly appointment, you must check whether the day of the month matches. Have the user enter a date and print out all appointments that occur on that date.

Respuesta :

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Explanation:

Java

   public class Appointment {

   private String description;

   private int day;

   private int mon;

   private int year;

   public Appointment(String desc, int day, int mon, int year)

   {

   description=desc;

   this.day=day;

   this.mon=mon;

   this.year=year;

   }

   public void occursOn(int day,int mon, int year)

   {

   }

   /**

 * "at"return the description

*/

public String getDescription() {

return description;

}

/**

* "at"param description the description to set

*/

public void setDescription(String description) {

this. description = description;

}

/**

* "at"return the day

*/

public int getDay() {

return day;

}

/**

* "at"param day the day to set

*/

public void setDay(int day) {

this. day = day;

}

/**

* "at"return the mon

*/

public int getMon() {

return mon;

}

/**

* "at"param mon the mon to set

*/

public void setMon(int mon) {

this. mon = mon;

}

/**

* "at"return the year

*/

public int getYear() {

return year;

}

/**

* "at"param year the year to set

*/

public void setYear(int year) {

this. year = year;

}

}

Daily. java

package com. study1;

public class Daily extends Appointment{

public Daily(String desc, int day, int mon, int year) {

// TODO Auto-generated constructor stub

super(desc, day, mon, year);

}

public void occursOn(int day, int mon, int year)

{

System. out. println(getDescription() + " is fixed");

}

}  

OneTime. java

package com. study1;

public class OneTime extends Appointment{

public OneTime(String desc, int day, int mon, int year) {

// TODO Auto-generated constructor stub

super(desc, day, mon, year);

}

public void occursOn(int day, int mon, int year)

{

if(getDay()==day && getMon()==mon && getYear()==year) {

System. out. println(getDescription() + " is fixed");

}

}

Monthly. java

package com. study1;

public class Monthly extends Appointment{

public Monthly(String desc, int day, int mon, int year) {

// TODO Auto-generated constructor stub

super(desc, day, mon, year);

}

public void occursOn(int day, int mon, int year)

{

if(getDay()==day) {

System. out. println(getDescription() + " is fixed");

}

}

}

Monthly. java

package com. study1;

public class Monthly extends Appointment{

public Monthly(String desc, int day, int mon, int year) {

// TODO Auto-generated constructor stub

super(desc, day, mon, year);

}

public void occursOn(int day, int mon, int year)

{

if(getDay()==day) {

System. out. println(getDescription() + " is fixed");

}

}

}

The output can be seen in the attached image below.

Ver imagen temmydbrain