Sample1_HelloWorld.java
Created with JBuilder |
import mads.core.*;
/**
* <p><H1>MADS Hello world</H1></p>
*
* <p><B>Sample project no. 1 </B><BR\> </p>
* This sample illustrates the simplest simulation possible: a hello world simulation. <BR\>
* The user should notice the following things:<BR\>
* <UL>
* <LI> All simulations are themselves agents<BR\>
* <LI> All simulations are based on a common agent type, called ASimulationAgent.
* This fact is specified by writing "extends ASimulationAgent" after the name of the simulation class.<BR\>
* <LI> In order to use the ASimulationAgent class (to inherit from it), one must include the package
* this class (and many others) are defined in. This package is called "mads.core" and, as it's
* name says, it contains the core of the MADS framework. To include this package, one has to
* add the "import mads.core.*;" command at the beginning of the simulation. For more complicated
* simulations, other packages will be included as well.<BR\>
* <LI> All the actual simulation work is done in the "doWork" function. Each simulation agent has to
* implement at least this function, or the simulation will not be compiled. Variables (expecially
* global ones) may be defined before the doWork functions, and other functions may be defined
* before or after as well.<BR\></p>
* </UL>
* <p>The only thing this simulation knows how to do is to to print a message. After the simulation is
* executed, the hello world text is printed. After the requested exit sequence is entered (Ctrl+C) or
* the stop button is pressed (if using JBuilder, the one with a red square), the simulation is over.
* </p>
*/
public class Sample1_HelloWorld extends ASimulationAgent
{
public void doWork(){
System.out.println("Hello world !!! \n My first simulation");
}
}
Sample1_HelloWorld.java
Created with JBuilder |