Question: This is in Java. Some of the code is done but needs some editing to it . Please fix the errors Firstly, I have this
This is in Java. Some of the code is done but needs some editing to it Please fix the errors
Firstly, I have this code as followed I need to Add the compareTo method.
package activity;
import java.util.;
public class Date
int month, day, year;
setting out private int variables
public Date set date to
default constructor
this.month ;
this.day ;
this.year ;
public Dateint month, int day, int year
three parameter constructor
this.year year;
this.day day;
this.month month;
public int getMonth
return month;
public void setMonthint newMonth
month newMonth;
public int getDay
return this.day;
public void setDayint newDay
day newDay;
public int getYear
return year;
public void setYearint newYear
year newYear;
public String toString
return monthdayyear;
public void printDate
System.out.printlnmonthdayyear;
After that, I need to create a subclass. "SpecialDate"
It has a new variable called description which describes the nature of the special date Such as "Birthday" or "Dinner Party" Include getset methods for this variable. For the default constructor, set the description to A Special Date
Include two constructors for the Special Date class, a default constructor, and a fourparameter constructor with a given month, day, year, and the description
Write the overridden method toString to return the string in the format of monthdayyear followed by the description such as Dad's birthday
Write the overridden method printDate to print the date in the same format as toString method.
Finally, write SpecialDateTest to test both the previous classes.
Create two objects of SpecialDate, one using the default constructor and another one using the fourparameter constructor. Both objects use SpecialDate as the data type.
Create another object of SpeicalDate; but use Date as the data type for the variable.
Compare the order of the three dates using compareTo method, one pair at a time.
Change the description of one of the dates using set method and print the new description using the get method.
Print all the dates using the overridden toString method.
Print all the dates using the overridden printDate method.
So as the final answer there should be three codes. One that is already written but needs a method added to the bottom, one that is SpecialDate and one to test both of those codes. SpecialDateTest
Please verify they work. Thank you!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
