ASSIGNMENT 10 In Assignment 6, you created a Month class (java file called Month
ID: 652918 • Letter: A
Question
ASSIGNMENT 10 In Assignment 6, you created a Month class (java file called Month.java) that holds the information about the month. Write exception classes for the following error conditions: Condition Class Name A number less than 1 or greater than 12 is given for the month number The only valid options for the month number are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12. InvalidMonthNumberException.java An invalid string is given for the name of the month (see Name above) The only valid options for the month names are: January, February, March, April, May, June, July, August, September, October, November, and December. (InvalidMonthNameException.java Modify the Month class so it throws the appropriate exception when either of these errors occurs. All the constructors (Month) and methods that are setting values for the month (SetMonthNumber, SetMonthName) should throw exceptions of that particular invalid month type (InvalidMonthNumberException, InvalidMonthNameException). Create a program/project called [YourName]-Assignment10 (replace [YourName] with your actual name) in the same project as the Month.java. You will need to add the class Month to the project and add your code to the project class main method. The program (code) should demonstrate that the exceptions for class Month work correctly. For example, try a month number between 1 and 12 and one not between 1 and 10 (e.g. -100, 100), try a month name in the range (e.g. May, October) and one not in the list (e.g. cat, apple, Monday, etc.) You can earn/loose additional points according to the following table: -5 For not documenting your code (should have a comment for each line of code , field, method, class, program, etc) -5 For not using the correct program name or file name that does not have your name in it -5 For not submitting the correct files -30 For hardcoding the results ; i.e. printing out the expected results instead of computing the values and then outputting the computed values -50 For cheating Take a screenshot of the editor window (showing the source code and the output) and save it as [YourName]- Screenshot (make sure you preserve the image file extension) or paste it in a document called [YourName]- Screenshot. Replace [YourName] with your actual name. If you have different output or code you want to capture in your screenshot, create and submit different screenshot files. Document your program (meaning follow the Assignment Code Convention, explain what each line of code does).
Explanation / Answer
The following program might help you.