Question: Write a java program in which : Write a class named RRCDate encapsulating the concept of a date. A date has the following integer attributes:
Write a java program in which :
Write a class named RRCDate encapsulating the concept of a date. A date has the following integer attributes: year, month and day.
Include appropriate constructors, accessors, mutators and equals methods. The default date is October 1, 1582. Ensure that the month can only be set to a value between 1 and 12. If the month value is invalid, the month is set to its default value. Ensure that the year can only be set to a 4-digit value greater than 1581.
If the year value is invalid, the year is set to its default value.
Include a method called getLongMonth which returns the month as a String (ex. the month value 6 would return June).
Include a toString method that returns the String representation of the date in the following format: {month}/{day}/{year} Example: 10/1/1582
Include a method called getLongFormat that returns the String representation of the date in the following format: {month} {day}, {year} Example: October 1, 1582
Include a static method called isLeapYear that accepts a year argument and returns true when the year is a leap year, otherwise it returns false.
In the Gregorian calendar three criteria must be taken into account to identify leap years: The year can be evenly divided by 4; If the year can be evenly divided by 100, it is NOT a leap year, unless; The year is also evenly divisible by 400. Then it is a leap year.
Programming Requirements Do not use any built-in Java date classes or functions. Ensure your class and its members are documented using Javadoc style documentation. Optional Challenge Ensure that the day can only be set to a value between 1 and the maximum value for the month.
Note: Each month has a specific number of days. February has a different number of days during a leap year. If the day value is invalid, the day is set to its default value. 2. Write a program that tests the following class members: Constructors Year accessor and mutator methods isLeapYear method Ensure all outcomes are tested. Optional Challenge Test the remaining methods of the class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
