~/ learn/ comp-308/ cards/ Part 1 recap: events, parsing, exceptions, serialize & restore
1 of 8

Type the parameterized Bell: rings stored in the ctor, looped in action

Type the parameterized Bell: rings stored in the ctor, looped in action

Answer

public class Bell extends Event { private int rings; public Bell(long delayTime, int rings) { super(delayTime); this.rings = rings; } public void action() { for (int i = 0; i < rings; i++) System.out.println("Bing!"); } }

The event file line "Event=Bell,time=9000,rings=5" drives this: the parser passes rings to the ctor; action() rings that many times. The framework grew by ONE new field + a loop.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/27f5163f-390e-4c37-893d-a9e195435bba/flashcard utf-8 LF