Report.java

The final class that needs to be implemented is the FinalReport class. The main purpose of this class is to provide any final details and report on the simulation. Keep in mind that an implementation of this class is only required if you specify that it is necessary for the Controller class to invoke it in the Simulation.properties file.

Since the sample problem required us to report the flight time, impact velocity and the maximum height that were achieved during the simulation, the only time these can be reported occurs after the simulation is complete. The source code for this class shows the following classes must be included for compilation.

import java.text.DecimalFormat;
import java.util.Iterator;
import feynman.framework.system.FinalReport;
import feynman.framework.system.PhysicalSystem;
import feynman.framework.simulation.Simulation;
This is just like the Measurement.java class. The class definition should be very familiar now including the instance variables.
public class Report implements FinalReport {
	
	// --------------------------------------------- instance variables.
	private Iterator i;
	private Ball b;
	private DecimalFormat df = new DecimalFormat("###.00");
The decimal format uses a format that will display optional numbers to the left and zeroes to the right. To satisfy the FinalReport API the class must provide an implementation of the report method.
public void report(Simulation sim, PhysicalSystem ps) {

// Retrieve the reference to the ball from the PhysicalSystem.
i = ps.iterator();
b = (Ball) i.next();

// Print out some final statistics.
System.out.println();
System.out.println("---------- Simulation Report -----------");
System.out.println("max height:         " + df.format(b.getMaxheight()) + " m");
System.out.println("impact velocity:   " + df.format(b.getVy()) + " m/s");
System.out.println("total flight time:  " + df.format(sim.getTime()) + " s");
System.out.println("----------------------------------------");

}
The implementation starts off by retrieving tha Ball object from the PhysicalSystem. It then produces a simple text report that includes querying the Ball object for its maximum height and velocity (impact velocity at this point). It the reports the total flight time by querying the simulation object for the last known value of the time before the simulation was stopped.

We are done! That is it. If you understand all of this then you are ready to start developing your own simulations using the Framework. Well almost. Next you have to learn how to tell the Framework Controller about the classes you developed. The next section provides information on how to alter the Simulation.properties file for your applications.

Previous Section | Next Section