Question: Task 2 - Checkpoint 3 3 Modify the program from Task 1 so that the length of the array event is specified with a constant
Task Checkpoint
Modify the program from Task so that
the length of the array event is specified with a constant a private final int named EVENTMAX. You will need to create the constant assign the value to it and then use it as the size specifier for the array.
the method recordEvent checks that there is room remaining in the array event to store another event Hint: compare xevent and EVENTMAX If there is not then the message:
Event log overflow terminating
should be output and the program terminated with the following method call:
throw new ArrayIndexOutOfBoundsException;
Modify the method main to be following:
public class RecordEvents
public static void mainString args
Recorder r new Recorder "Wombat Detection";
rrecordEvent:;
rrecordEvent:;
for int i ; i ; i
String s intMathrandom:intMathrandom;
rrecordEvents;
rprintEvents;
Run the program. The output produced should be:
the line numbers in the exception message could be different
Event log overflow terminating
Exception in thread"main"java.lang.ArrayIndexOutOfBoundsException
at Recorder.recordEventRecorderjava:
at RecordEvents.mainRecordEventsjava:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
