Question: Write a class definition for Date in a separate file called Date.java with the following specifications: a) b) c) e) The Date object will

Write a class definition for Date in a separate file called Date.java

 with the following specifications: a) b) c) e) The Date object will contain three integers: year, month, and day. This class should provide two

Write a class definition for Date in a separate file called Date.java with the following specifications: a) b) c) e) The Date object will contain three integers: year, month, and day. This class should provide two constructors. The first should take no parameters and initialize it to a default date for 1/1/2023. The second should take parameters named yy, mm and dd, and use them to initialize the instance variables year, month and day respectively. There should be a getter and setter method for each of the data members. Hence, you should have these getter methods: getYear (), getMonth (), get Day () and also setter methods: set Year(), set Month (), set Day () There should be an instance method called print () that will print the date in the format month/day/year format There should also be another instance method called set Date () that will set all the data components of year, month and day at once rather than one by one. Write a test program (with the main method) in a separate file that will create two Date objects called: date1 using the default constructor birthday using the other constructor and set values to your own birthday date Then print the date1 object. After this, call the set Date () method on the date1 object to set date a different date o your own choice. Lastly, call the print() method on both the date1 object and birthday object. Remember to also print text information to clearly show that this is for date1 and this is for birthday object. Do this in the main method.

Step by Step Solution

3.41 Rating (160 Votes )

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 Programming Questions!