Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It is JAVA. Please solve this question. It should be an output. Thank you For each of the programming assignment please make sure to create

image text in transcribedimage text in transcribedimage text in transcribedIt is JAVA.

Please solve this question. It should be an output.

Thank you

For each of the programming assignment please make sure to create a Tester class that tests and shows that your program code has been properly tested and verified. Make sure to include the test output below the Tester class code in a commented section. A. Write a class CalendarDay that creates a valid date and stores the month, day, and year in three separate instance variables inside the object. The class should contain the following methods: A constructor that takes String data in the form "month/day/year" and initializes the instance variables. For example, new CalendarDay ("12/25/2000") should create a valid instance of the CalendarDay with month = 12, day = 25, and year = 2000. A constructor that takes three separate integer parameters month, day, and year and initializes the instance variables. For example, new CalendarDay (11,20,2016) should create an valid instance of the CalendarDay with month = 11, day = 20, and year = 2016. A copy constructor Accessor and mutator methods for month, day, and year. Override the equals method that compares the current object with another object and return the correct results. A toString method that returns a String description of the object. . Additional requirements for the class: The months should be implemented as a group of enumerable objects, with each month verifying the validity of the day based on year and month, The CalendarDay should implement the Comparable interface and return the correct results when compared to another CalendarDay object. You should define three exception classes, one called MonthException, another called DayException, and a third called YearException. The class constructors should check the validity of the input and throw the appropriate exceptions. If the month supplied is anything other than a legal month number (integers from 1 to 12), your class should throw a MonthException. Similarly, if the day is not a valid day number (integers from 1 to either 28, 29, 30, or 31, depending on the month and year), then your class should throw DayException. If the year is not in the range 1000 to 3000 (inclusive), then the class should throw a YearException. (There is nothing very special about the numbers 1000 and 3000 other than giving a good range of likely dates.) The mutator methods should throw an exception if the parameters are invalid or changes the object to an inconsistent state. When changes are made to the month or day or year, it should verify to make sure that it is a valid day. If not, these methods should throw one of the above exception with a meaning message. Create a Tester class and test all the methods, including throwing and catching exceptions. Use a loop and the try-catch statements in the main method that gives the user an opportunity to re-enter the month, day, and date when an exception is thrown by the CalendarDay class constructors. Also, create an array of random CalendarDay objects and use the Arrays.sort method to sort these objects

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

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

Students also viewed these Databases questions

Question

What are some of the downsides of activity-based costing systems?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago