Question
In Java 8.0 The Date class. The Date class will represent a date. (Java has both Date and Calendar in the API, but both are
In Java 8.0
The Date class. The Date class will represent a date. (Java has both Date and Calendar in the API, but both are more complex than needed for this homework.) A Date contains a day, month, and a year. The Date class should have the following methods:
-
getDay: takes no input and returns an int that is the day of the date. The day should be a value between 1 and 31.
-
getMonth: takes no input and returns an int that is the month of the date. The month should be between 1 and 12.
-
getYear: takes no input and returns an int that is the year of the date.
-
incrementDay: takes no input and returns nothing. The method adds 1 to the day of the date. If the day exceeds the number of days for the month (assume no leap years), the day is set to 1 and the month is incremented. If the month exceeds 12, the month is set to 1 and the year is incremented.
-
toString: overrides the toString method inherited from Object so that the string returned is the date in "xx/xx/xxxx" format.
-
equals: overrides the equals method inherited from Object so that the method returns true if the input is a Date object (our Date, not the API Date) with the same month and day (the year may be different). Otherwise the method returns false.
The Date class should have one constructor:
-
It has input int day, int month, int year and initializes the Date object with the given inputs. You may assume that the inputs are all valid values.
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