Question: In Java, only can use the methods provided. The Date class. The Date class will represent a date. (Java has both Date and Calendar in

In Java, only can use the methods provided.

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:

  1. 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.

  2. getMonth: takes no input and returns an int that is the month of the date. The month should be between 1 and 12.

  3. getYear: takes no input and returns an int that is the year of the date.

  4. 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.

  5. toString: overrides the toString method inherited from Object so that the string returned is the date in "xx/xx/xxxx" format.

  6. 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:

  1. 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

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!