Question
JAVA. This is my third time reposting this question. I need DATETEST class written to fit my ALREADY WRITTEN date.java. thank you! Write DateTest class
JAVA. This is my third time reposting this question. I need DATETEST class written to fit my ALREADY WRITTEN date.java. thank you! Write DateTest class which includes the main method. The program should create three objects of the Date class and one of them should use the default constructor and the other two use three-parameter constructor. Print all three dates using toString method. Change the month, day, and year of one of the dates using set methods, and then use get methods to display the new value of month, day, and year. Print all three dates again using printDate method. (please include comments) Here is my "date.java" I just need you to help with the test class package
class Date {
// month, day, and year as private instance variables.
private int month;
private int day;
private int year;
//default constructor
public Date() {
// set the date to 1/1/2000
this.month = 1;
this.day = 1;
this.year = 2000;
}
// three-parameter constructor will include a given month, day, and year as parameters.
public Date(int month, int day, int year) {
this.month = month;
this.day = day;
this.year = year;
}
// get month
public int getMonth() {
return month;
}
// set month
public void setMonth(int month) {
this.month = month;
}
// get day
public int getDay() {
return day;
}
// set day
public void setDay(int day) {
this.day = day;
}
// get year
public int getYear() {
return year;
}
// set year
public void setYear(int year) {
this.year = year;
}
//toString method to return the date in month/day/year format as a string.
@Override
public String toString() {
return month + "/" + day + "/" + year;
}
//printDate method to print the date in month/day/year format.
public void printDate(){
System.out.println(month + "/" + day + "/" + year);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started