Question: JAVA HELP - Use the following template: Rewrite the definitions of the method setDate and the constructor with parameters so that the values for the

JAVA HELP -

Use the following template:

Rewrite the definitions of the method setDate and the constructor with parameters so that the values for the month, day, and year are checked before storing the date into the data members.

Add a method member, isLeapYear, to check whether a year is a leap year.

Write a test program to test your class

public class Date { private int dMonth; //variable to store the month private int dDay; //variable to store the day private int dYear; //variable to store the year //Default constructor //Data members dMonth, dDay, and dYear are set to //the default values //Postcondition: dMonth = 1; dDay = 1; dYear = 1900; public Date() { dMonth = 1; dDay = 1; dYear = 1900; } //Constructor to set the date //Data members dMonth, dDay, and dYear are set //according to the parameters //Postcondition: dMonth = month; dDay = day; // dYear = year; // This constructor needs to be rewitten **************************** public Date(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } //Method to set the date //Data members dMonth, dDay, and dYear are set //according to the parameters //Postcondition: dMonth = month; dDay = day; // dYear = year; // This constructor needs to be rewitten **************************** public void setDate(int month, int day, int year) { dMonth = month; dDay = day; dYear = year; } //Method to return the month //Postcondition: The value of dMonth is returned public int getMonth() { return dMonth; } //Method to return the day //Postcondition: The value of dDay is returned public int getDay() { return dDay; } //Method to return the year //Postcondition: The value of dYear is returned public int getYear() { return dYear; } //Method to return the date in the form mm-dd-yyyy public String toString() { return (dMonth + "-" + dDay + "-" + dYear); } // This method checks whether a year is a leap year // Write the code for this method *********************************** public boolean isLeapYear() { } } 

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!