Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Define the class called Date which will be used to read, create, and manipulate dates. The class has 3 instance variables as shown below:

JAVA

Define the class called "Date" which will be used to read, create, and manipulate dates. The class has 3 instance variables as shown below:

private int day;

private int month;

private int year;

The class should have a constructor public Date(int day, int month, int year) to create a new Date type object given parameters for day, month and year. No error handling is needed here in this constructor

The class should also have a constructor method to create a new Date type object from an existing Date type object (i.e.copy constructor).

The class also needs an additional constructor which can create a Date type object from by taking into a string in the form of "DD/MM/YYYY". Where DD is for day, MM is month (a preceding 0 will be used for days and months less than 10, ex. Jan 1 is 01/01), and YYY is the year. The constructor may use any classes and/or methods you choose to accomplish this task, but I will point you towards the substring method in String, and the static method parseInt of the wrapper class Integer as a good method to look at.

The class should have an accessor method for each of the three instance variables

Define an equals method, boolean equals(Date date) , to compare the contents of two Date objects to see if they are equal

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago