Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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