Question
Please fill out the code by using Java Array! /* This class encapsulates a list of user events, where an event * is represented by
Please fill out the code by using Java Array!
/* This class encapsulates a list of user events, where an event * is represented by a String object. */ public class EventSchedule { //Class member variable declarations: /* Constructor that initializes the event list and any other * variables. */ public EventSchedule(){ } /* Add the event passed in to the end of the list. * For example, if the list contained: event1, event2, * the next event added, event3, would result in this list: * event1, event2, event3. */ public void addEvent(String eventStr){ } /* Overwrite the event at "position" to be the parameter "eventStr". * Note: position is a positive integer > 0 that has to be a valid position * in the eventList. A valid position corresponds to an event stored in the * eventList. For example, if this was the list: 1 walk the cat 2 order doughnuts 3 go to the gym 4 wash dishes * valid positions would be 1, 2, 3, 4. All other integers are invalid. * This method returns true if a valid position was passed in, false otherwise. */ public boolean replaceEventAt(String eventStr, int position){ return false; } /* Remove the last event in the eventList. * For example, if the list contained: event1, event2, event3, * removing the last event would result in this list: * event1, event2. * This method returns true if there is at least one event in the list, * false otherwise. */ public boolean removeLastEvent(){ return false; } /* Return the event list as an array of Strings. * Note that the array should contain only the events * on the list in the correct order (index 0 is position 1) * and no empty cells (null values). */ public String[] getEventListAsArray(){ return null; } /* Remove all events from the list, resulting in an empty list. */ public void clearEventList(){ } /* Returns a String representation of the current event list according to * these specifications: * Each event is on one line, position number first followed by one blank, * followed by the event String. * For example: 1 walk the cat 2 order doughnuts 3 go to the gym 4 wash dishes * If no events are on the list the String returned is: "no events". */ public String getEventStr(){ return null; } /* Returns the number of events stored in the event list. */ public int getSize(){ return 0; } /* Returns true if the event list contains no events, false otherwise. */ public boolean isEmpty(){ return false; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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