Implement a superclass called Appointment and subclasses OneTime, Daily, Weekly,
ID: 3534606 • Letter: I
Question
Implement a superclass called Appointment and subclasses OneTime, Daily, Weekly, and Monthly. An Appointment has a descriptionand a date and time. Write a method occursOn(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then, in a TestAppointment class, fill an array of Appointment objects with a mixture of different kinds of appointments. Ask a user to enter a date and print out all appointments that occur on that date.
B. Improve your Appointment program by giving the user the option to add new Appointments. The user must specify the type of the appointment, the description, and the date and time.
As always, the source code must be indented properly and contain comments that describe important parts of the algorithm.
Explanation / Answer
Appointment findDate( String date ) { if( this.date = date )return this; return null; } public Appointment findDesc(description string) { if( this.description = description ) return this; return null; } TestAppointment has a datastore, such as ArrayList alist = ArrayList(). You go through that a list Appointment detail = null; for( Appointment a : alist ) { if( a.description( "dentist" ) != null ) detail = a; break;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.