Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How does Method implement the marketing concept?

Answered: 1 week ago