(JAVA) In this assignment, you will implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, “see the dentist”) and a date. 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 mon.th matches.
In your application part, fill an array of Appointment objects with a mixture of appointments. Have the user enter a date and print out all appointments that occur on that date.
Requirements:
package inheritance;
// Defines a class Appointment
class Appointment
{
String description;
// Parameterized constructor
Appointment(String des)
{
description = des;
}// End of parameterized constructor
// Overrides toString() method to return description
public String toString()
{
return "\n\n Appointment Information: " + description;
}// End of method
}// End of class Appointment
// Creates a derived class Onetime from super class Appointment
class Onetime extends Appointment
{
int day;
int month;
int year;
// Parameterized constructor
Onetime(String des, int y, int m, int d)
{
super(des);
day = d;
month = m;
year = y;
}// End of parameterized constructor
// Overrides toString() method to return one time appointment information
public String toString()
{
return super.toString() + "\n Appointment Date: " + day + "/" + month + "/" + year;
}// End of method
}// End of class Onetime
// Creates a derived class Daily from super class Appointment
class Daily extends Appointment
{
int day;
// Parameterized constructor
Daily(String des, int d)
{
super(des);
day = d;
}// End of parameterized constructor
// Overrides toString() method to return daily appointment information
public String toString()
{
return super.toString() + "\n Appointment Day: " + day;
}// End of method
}// End of class Daily
// Creates a derived class Monthly from super class Appointment
class Monthly extends Appointment
{
int month;
// Parameterized constructor
Monthly(String des, int m)
{
super(des);
month = m;
}// End of parameterized constructor
// Overrides toString() method to return monthly appointment information
public String toString()
{
return super.toString() + "\n Appointment Day: " + month;
}// End of method
}// End of class Monthly
// Driver class definition
public class AppointmentTest
{
// Declares an array of object of class Appointment
static Appointment app[];
// Defines a method to check the appointment date and displays information
static void occursOn(int year, int month, int day)
{
// Sets the found status to 0 for not found appointment
int flag = 0;
// Loops till number of appointment
for(int c = 0; c < app.length; c++)
{
// Checks if current object is of type Onetime class
if(app[c] instanceof Onetime)
{
// Converts the current object to Onetime class object
Onetime o = (Onetime)app[c];
// Checks if year, month and day of parameter is equals to
// the current object year, month and day
if(o.year == year && o.month == month && o.day == day)
{
// Sets the flag value to 1 for found appointment
flag = 1;
// Displays the current object information
System.out.println("\n *********** One Time Appointment ***********");
System.out.println(o);
}// End of if condition
}// End of if condition
// Otherwise checks if current object is of type Daily class
else if(app[c] instanceof Daily)
{
// Converts the current object to Daily class object
Daily d = (Daily)app[c];
// Checks if current object day is equals to parameter day
if(d.day == day)
{
// Sets the flag value to 1 for found appointment
flag = 1;
// Displays the current object information
System.out.println("\n *********** Daily Appointment ***********");
System.out.println(d);
}// End of if condition
}// End of else if condition
// Otherwise current object is of type Monthly class
else
{
// Converts the current object to Monthly class object
Monthly m = (Monthly)app[c];
// Checks if current object month is equals to parameter month
if(m.month == month)
{
// Sets the flag value to 1 for found appointment
flag = 1;
// Displays the current object information
System.out.println("\n *********** Monthly Appointment ***********");
System.out.println(m);
}// End of if condition
}// End of else
}// End of for loop
// Checks if flag value is 0 then appointment is not available on the date
if(flag == 0)
// Displays the not found information
System.out.println("\n No Appointment on: " + day + "/" + month + "/" + year);
System.out.println("\n *********** *********** ***********\n");
}// End of method
// main method definition
public static void main(String s[])
{
// Declares an array of object of class Appointment of size 6
app = new Appointment[6];
// Creates object of class Onetime
app[0] = new Onetime("see the cardiology", 2010, 10, 2);
app[1] = new Onetime("see the gynic", 2019, 5, 28);
// Creates object of class Daily
app[2] = new Daily("see the dentist", 2);
app[3] = new Daily("see the pedeatric", 9);
// Creates object of class Monthly
app[4] = new Monthly("see the gynic", 5);
app[5] = new Monthly("see the dentist", 4);
// Calls the method to check the appointment
occursOn(2010, 10, 2);
occursOn(2020, 10, 14);
occursOn(0, 0, 2);
occursOn(0, 5, 2);
}// End of main method
}// End of driver class
Sample Output:
*********** One Time Appointment ***********
Appointment Information: see the cardiology
Appointment Date: 2/10/2010
*********** Daily Appointment ***********
Appointment Information: see the dentist
Appointment Day: 2
*********** *********** ***********
No Appointment on: 14/10/2020
*********** *********** ***********
*********** Daily Appointment ***********
Appointment Information: see the dentist
Appointment Day: 2
*********** *********** ***********
*********** Daily Appointment ***********
Appointment Information: see the dentist
Appointment Day: 2
*********** Monthly Appointment ***********
Appointment Information: see the gynic
Appointment Day: 5
*********** *********** ***********
(JAVA) In this assignment, you will implement a superclass Appointment and subclasses Onetime, Daily, and Monthly....
Programming language: JAVA Implement a superclass Appointment and subclasses OneTime, Daily, and Monthly. An appointment has a description (for example "see the dentist") and a date. 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, check whether the day of the month matches. Ask the user to enter a date to check (for example, 2006 10 5), and ask to user if they want...
Help me with a python program : Implement a superclass appointment and subclasses Onetime, Daily and Monthly. An appointment has a description(for example, "See the dentist") and a date. Write a method occursOn(year, month, 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 fill a list of appointment objects with a mixture of appointments. Have the user enter a date and print...
Write a Java program that implements a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has a description (for example, “see the dentist”) and a date. It writes a method occursOn (int year, int month, int day) that checks whether the appointmentoccurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then it will fill an array of Appointment objects with a mixture of appointments. When the user...
*PYTHON* Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment has the date, the month, the year, and the description of an appointment (e.g., “see the dentist”). Then, write a method occcursOn(year, month, day) that checks whether the appointment occurs on that date. In the test program, you should create a list of appointments using your subclasses of Onetime, Daily, and Monthly. Once you have those appointments available, allow the user to input day, month, and year...
5.Implement a superclass Appointment and subclasses Onetime, Daily and Monthly. An appointment has a description (for example, “see the dentist”) and a date. Write a method occursOn(year,month,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 and the appointment date started before the date entered. Then, fill a list of Appointment objects with a mixture of appointments. Have the user enter a date and...
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...
Programming Assignment 6 Write a Java program that will implement a simple appointment book. The program should have three classes: a Date class, an AppointmentBook class, and a Driver class. • You will use the Date class that is provided on Blackboard (provided in New Date Class example). • The AppointmentBook class should have the following: o A field for descriptions for the appointments (i.e. Doctor, Hair, etc.). This field should be an array of String objects. o A field...
In this assignment, you will write a Java program(s) to print the binary representation of a positive integer inserted from command line. You must finish your assignment in 2 different ways: Using a recursive method Using an iterative method Your main method must be: public static void main(String[] args) { int input; input = Integer.parseInt(args[0]); print_recursion(input); print_binary(input); } You must implement a class and test your program by different input values, including 0. Comment your program properly Example of test...
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...
Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...