Question
// o f the event type as parameters c l a s s Recorder { i n t xPos , yPos ; St r ing
// o f the event type as parameters c l a s s Recorder { i n t xPos , yPos ; St r ing eventType ; St r ing [ ] event = new St r ing [ 5 ] ; i n t xevent = 0 ; // keeps t rack o f how many event s have oc cur r ed Recorder ( i n t xPos , i n t yPos , St r ing eventType ) { t h i s . xPos = xPos ; t h i s . yPos = yPos ; t h i s . eventType = eventType ; } void recordEvent ( St r ing eventTime ) { event [ xevent ] = eventTime ; xevent++ ; } void pr intEvent s ( ) { System . out . p r i n t l n ( " Record o f " + eventType + " event s at [ " + xPos + " , " + yPos + " ] " ) ; // Task 1 : // Add a f o r loop below t h i s l i n e to pr i nt out each event ( s e e task 1 spec ) // Note that not a l l 5 elements o f the array are n e c e s s a r i l y used // The v a r i a b l e xevent i s always one bi g g e r than the index o f the l a s t // event r e corded . For example , a f t e r two event s have been r e corded ( as // in the method main above ) the value o f xevent wi l l be 2 . } } Task 1 Add a for loop to the method printEvents to print out each event (see last 2 lines of the example below). Compile and run the program. The output produced should be: Record of Wombat Detection events at [100,100] Event number 0 was recorded at 10:53 Event number 1 was recorded at 10:59
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