Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class to represent a date. A date has a month, day, and year. Your date class should support the following operations: 1.
Write a class to represent a date. A date has a month, day, and year. Your date class should support the following operations: 1. Create a date object. Write a constructor that takes initial values for day, month, and year 2. Create a date object from an existing date object. A copy constructor. 3. toString() return a String representation of the date in the American format (i.e., January 1, 2018) - 4. Add one day to the date 5. Subtract one day from the date 6. [Optional]. Add d days to the date where d is a parameter to the method 7. Add one month to the date 8. Subtract one month from the date 9. Return the number of days past January 1. 10. Implement a compareTo method that tells you whether another date is before you, the same as you, or comes after you. Remember that compareTo returns a negative value, zero, or positive value. Write a Date class and a tester that enables you to test the class by testing the methods as many times as you want in any order with different data. You can ignore leap year. Your tester should display a menu of choices in a loop. Upload your UML diagram, all of your java files, and a snip of the output to show that it works. Hint: Create an array that has the number of days in each month.
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