You are to create a class Appointment.java that will have the following: 5 Instance variables: private String month private int day private int year private int hour private int minute 1 default...


You are to create a class Appointment.java that will have the following:


5 Instance variables:



  • private String month

  • private int day

  • private int year

  • private int hour

  • private int minute


1 default constructor


public Appointment()


1 non-default constructor that accepts arguments for all instance variables, your constructor must call the setter methods below to set the values of the instance variables


public Appointment(String monthPassed, int dayPassed, int yearPassed, int hourPassed, int minutePassed)


5 setter methods (one for each instance variable) with these limits:


//the setter for the month must determine if the


//month passed is a valid month


//(January - December), if not the month


//must be saved as %u201CUnknown%u201D


//if you would like (this is not required) you can ask the user to


//enter another month if the month is not


//valid and trap them until they enter a valid month


public void setMonth(String monthPassed)


//the setter for hour must confirm that the hour is


//between 0 and 23 (inclusive) if it is not set the


//hour as -1


//if you would like (this is not required) you can ask the user to


//enter another hour if the hour is not


//valid and trap them until they enter a valid hour


public void setHour(int hourPassed)


//the setter for year must confirm that the year


//is >= 0, if it is not set the year as -1


public void setYear(int yearPassed)


//the setter for minute must confirm that the


//minute is between 0 and 59 (inclusive) if it is


//not set the minute as -1


//if you would like (this is not required) you can ask the user to


//enter another minute if the minute is not


//valid and trap them until they enter a valid minute


public void setMinute(int minutePassed)


//the setter for day must confirm that the


//day is between 0 and 31 (inclusive) if it is


//not set the day as -1


//if you would like (this is not required) you can ask the user to


//enter another day if the day is not


//valid for that month (you would have to determine


//if the year is a leap year to do this for


//the month of February) and trap them until they enter a valid day


//for that month and year


public void setDay(int dayPassed)


5 getter methods (one for each instance variable) that return the value of the variable



  • public String getMonth()

  • public int getDay()

  • public int getYear()

  • public int getHour()

  • public int getMinute()


1 toString method


public String toString()


1 equals method


public boolean equals(Appointment appointmentPassed)


You are to then create a class DemoAppointment.java that will


Declare and create:


An instance of the class Appointment (named a1) that will be created through the default constructor


An instance of the class Appointment (named a2) that will be created through getting from the user values for each instance variable and passing those values to the non-default constructor


Print to the screen the values of the instance variables of a1 and a2 above (use the toString method)


Print to the screen if a1 and a2 above are or are not equal (use the equals method).


May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here