Question: JAVA PROGRAMMING Add these private helper methods: private boolean isLeapYear(int yyyy) // returns true if the year argument is a leap year, otherwise returns false
JAVA PROGRAMMING
Add these private helper methods:
private boolean isLeapYear(int yyyy) // returns true if the year argument is a leap year, otherwise returns false
private int daysInMonth(int mm, int yyyy) // returns the number of days in the month for the month mm and year yyyy
private boolean isValidDate(int mm, int dd, int yyyy) // returns true if the arguments are a valid date, otherwise return false
Add these public methods:
public boolean isLeapYear() // returns true if this year is a leap year, otherwise returns false
For example, 2020 is a leap year so should return true, 2017 is not a leap year so should return false
public int daysInMonth() // returns the number of days in this month
For example, if the date is 3/12/2015, the number of days to be returned is 31, because there are 31 days in March.
public int daysPassedThisYear() // returns the number of days passed this year to date.
For example, if the date is 3/18/2015, the number of days passed in the year is 77. Note that the number of days returned also includes the current day.
public int daysRemainingThisYear() // returns the number of days in this year after this date.
For example, if the date is 3/18/2015, the number of days remaining in the year is 288.
public Date addDays(int days) // return a new Date object after adding a days to this Date.
For example, if the date is 3/18/2015 and the days to be added are 25, the new date is 4/12/2015.
public Date(Date otherDate) // constructs and returns a new Date object with data members copied from otherDate object.
public void save(String fileName) // analogous to the save() method in the Day class with a file extension of .date, first line of text file is "Date" and the second line is the month day year data from this Date object.
Should throw an IOException if fileName cannot be opened or is not a valid Date object file.
public Date load(String fileName) // analogous to the load() method in the Day class with format created in Date.save().
Also throws an IOException if there is a problem with fileName.
The method setDate() and the constructor with parameters do not check whether the date is valid before storing the date in the data members.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
