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 activity4;
import java.util.*;
public class Date
{
int month, day, year;
// setting out private int variables
public Date()// set date to 1/1/2000
//default constructor
{
this.month =1;
this.day =1;
this.year =2000;
}
public Date(int month, int day, int year)
// three parameter constructor
{
this.year = year;
this.day = day;
this.month = month;
}
public int getMonth()
{
return month;
}
public void setMonth(int newMonth)
{
month = newMonth;
}
public int getDay()
{
return this.day;
}
public void setDay(int newDay)
{
day = newDay;
}
public int getYear()
{
return year;
}
public void setYear(int newYear)
{
year = newYear;
}
public String toString()
{
return month+"/"+day+"/"+year;
}
public void printDate(){
System.out.println(month+"/"+day+"/"+year);
}
}
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 get/set 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 four-parameter constructor (with a given month, day, year, and the description).
- Write the overridden method toString to return the string in the format of month/day/year followed by the description (such as 10/11/2000 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 four-parameter 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!