Question: You will create one program called MyCalendar.java. You should implement the MyCalendar and MyDate classes according to the following UML class diagrams. You can add

You will create one program called MyCalendar.java. You should implement the MyCalendar and MyDate classes according to the following UML class diagrams. You can add additional methods, but the existing attributes and methods cannot be modified

MyCalendar
- myDate: MyDate

+ main(String[])

+ MyCalendar(MyDate)

+ getDayOfWeek(): Day

+ getWeekOfMonth(): int

+ printDateInfo(): void

+ printCalendar(): void

Day is an enumerated data type which contains the days of the week, i.e., Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

MyCalendar is the constructor of the class MyCalendar.

getDayOfWeek method will return the day of the week for the given date.

getWeekOfMonth method will return the week of the month for the given date.

printDateInfo methods will print the information of the given date. The date is printed as dd/mm/yyyy and the ordinal week of the month in which the date is located.

For example, for the date of 19 October 2018 it should print as 19/10/2018 is a Friday and located in the third week of October 2018

printCalendar method will print the calendar of the given month.

main method will take a valid date from the command line as shown in the Testing section. If the input date is not a valid date, the program will ask user to input another valid date. This process will be repeated until a valid date is entered by the user. The valid input date will be used to create an instance of the class MyCalendar. The main method will also invoke the printDateInfo and printCalendar methods of a MyCalendar object respectively.

MyDate

- day: int

- month: int

- year: int

+ MyDate(int, int, int)

+ getDay(): int

+ getMonth(): int

+ getYear(): int

+ isDateValid(): boolean

MyDate is the constructor of the class MyDate.

getDay method will return the day.

getMonth method will return the month.

getYear method will return the year.

isDateValid method will return true when the date is valid, and false otherwise (notes: January, March, May, July, August, October, December has 31 days. April, June, September, November has 30 days. February has 29 days in a leap year, and 28 days in a common year.).

Testing

The output format shown in this section is a formative part of the requirements that your program should comply with. The following is a sample screenshot of running the correct and complete program that you can compare with your program. (User input is in red colour, results in blue colour and prompt lines in black colour. Colours in this paper are for readability only. Your program does not need to print in colour.)

You will create one program called MyCalendar.java. You should implement the MyCalendar

Step by Step Solution

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