Question: Here is the code: class Simulation { /** Interface allowing actions to be passed as lambda expressions */ public interface Action { void trigger( float

Here is the code:
class Simulation { /** Interface allowing actions to be passed as lambda expressions */ public interface Action { void trigger( float time ); } /** Events are queued for Simulation.run to find */ private static class Event { float time; Action act; // constructor Event( float t, Action a ) { time = t; act = a; }; void trigger() { act.trigger( time ); } } private static PriorityQueue eventSet = new PriorityQueue ( (Event e1, Event e2)->Float.compare( e1.time, e2.time ) ); /** Users call schedule to schedule one action at some time. * @param time specifies when the event should occur. * @param act specifies what to do at that time. * Typically, act is a lambda expression, so a call to schedule could * look like this: * * Simulation.schedule( t, (float t)->object.method( params, t ) ) *
*/ public static void schedule( float time, Action act ) { eventSet.add( new Event( time, act ) ); } /** the main program should build the model, * this inolves scheduling some initial events * and then, just once, it should call run. */ public static void run() { while (!eventSet.isEmpty()) { Event e = eventSet.remove(); e.trigger(); } } } 4. Background: Look at class simulation from the posted solution to MP4 A problem: List (in the order they occur in the code) all of the declarations in this code that can be marked as final. (l.0 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
