Question
Add a mutator method called addEvent() that takes an integer representing a day (0-6) and a corresponding Event object. Adding an event first requires determining
Add a mutator method called addEvent() that takes an integer representing a day (0-6) and a corresponding Event object.
Adding an event first requires determining where it belongs in the array. The day number can be used as-is when indexing into the array, but the hour number cannot, since the array has 10-hour positions (numbered zero through 9) to represent the times from 8 a.m. to 5pm (8 to 17, as simple ints). Therefore, remember to use the event's hour number minus 8 to index into the array. For example, adding a 9 am event on day 3 (Wednesday) would set the array value at location [3][1].
When adding an event, if the day parameter is invalid or the event's hour number is out of the 8-17 range, the method should simply do nothing. Otherwise, you can update the array.
Add an accessor method called getEvent() that takes an integer representing a day (0-6) and a second integer representing an hour (0-23). It should return the corresponding event, if any (again, don't forget to subtract 8 from the hour when looking in the array), or null if there is no event at that time. It should also return null if either the day or time parameter is invalid. For example, retrieving the 9am event on day three will access position [3][1] in the array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The addEvent and getEvent methods public class EventPlanner ...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