Lesson6
Posted: Wed Sep 02, 2020 2:54 pm
Create the project SimulationApp.
Add osp.jar to the project.
Add osp.jar to the project.
Easy English Study
https://easy-english-study.com/forum/
Code: Select all
package simulationapp;
import org.opensourcephysics.controls.AbstractSimulation;
import org.opensourcephysics.controls.SimulationControl;
public class SimulationApp extends AbstractSimulation{
int counter = 0;
public void doStep(){
// does a simulation step
control.println("Counter = "+(counter--));
}
public void initialize(){
counter = control.getInt("counter");
}
public void reset(){
//invoked when reset button is pressed
//allows dt to be changed after initialization
control.setAdjustableValue("counter",100);
}
public static void main(String[] args){
// creates a simulation structure using this class
SimulationControl.createApp(new SimulationApp());
}
}