Need a java program for this. Something comprehensive. It’s for java program 1.
ID: 3709951 • Letter: N
Question
Need a java program for this. Something comprehensive. It’s for java program 1. Thanks.Implement a superclass Appintment and subclasses Onetine, Daiy, and Monthly. has a description (for example, "see the dentist) An appointment and a date. Write a method eccursonCiet year, iet month, iet day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you nast check Aspeinteent objects with a misture of appointments Have the user enter a date and print out all appointments that occur on that date
Explanation / Answer
Scanner scanner = new Scanner(System.in);
String Appointment_Description;
int year;
int month;
int day;
Date date;
String Str_Date;
public Date OccursOn(int year , int month , int day){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
Str_Date = " year" + year + " month" + month +" day" +day ;
Appointment_Description = "Today Date" + Str_Date + "is your Dentist Appointment";
System.out.println("Appointment_Description");
return date;
}
}
.................................................................................
package com.appointment;
import java.util.Date;
public class Onetime extends Appointment {
int day;
int month;
int year;
@Override
public Date OccursOn(int year, int month, int day) {
// TODO Auto-generated method stub
return super.OccursOn(year, month, day);
}
}
................................................................................................
package com.appointment;
import java.util.Date;
public class Daily extends Appointment{
int day;
int month;
int year;
@Override
public Date OccursOn(int year, int month, int day) {
// TODO Auto-generated method stub
return super.OccursOn(year, month, day);
}
}
..............................................................................................................
package com.appointment;
import java.util.Date;
public class Monthly extends Appointment{
int day;
int month;
int year;
@Override
public Date OccursOn(int year, int month, int day) {
// TODO Auto-generated method stub
return super.OccursOn(year, month, day);
}
}
....................................................................................................................
package com.appointment;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.Scanner;
public class TestClass {
Date date;
public Date getDate(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
return date;
}
Appointment App = new Appointment();
// Daily Appointment Object
static Appointment d1 = new Daily();
// Monthly Appointment Object
Appointment m1 = new Monthly();
// OneTime Appointment object
Appointment o1 = new Onetime();
public static void main(String[] args) {
ArrayList<String> appoint = new ArrayList<String>();
{
// Add For loop to Set the Appointments
String d1;
String d2;
String d3;
}
// appointMent Added to the Array
appoint.add(d1);
appoint.add(d2);
appoint.add(d3);
// Printing the Dates of the Appointment.
for(String obj: appoint)
System.out.println(obj);
}
}
kindly rate....
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.