Class Simulation

java.lang.Object
  extended by Simulation
Direct Known Subclasses:
BirdSimulation, CrowdSimulation, DESimulation, DiseaseSimulation, PoliticalSimulation, WDSimulation

public class Simulation
extends Object

Class that implements a general Simulation

Author:
Mark Guzdial, Barb Ericson

Constructor Summary
Simulation()
          Constructor to set output to null
Simulation(Picture bg)
          Constructor to set output to null
 
Method Summary
 void add(Agent newOne)
          Add this actor to the agents list
 void closeFile()
          close the file and clear the output stream
 void endStep(int t)
          End of step processing
 LinkedList getAgents()
          Get a linked list of all agents
 BufferedWriter getOutput()
          Method to get the BufferedOutput to write to
 World getWorld()
          Method to get the world
 void openFile(String filename)
          Open the input file and set the BufferedWriter to speak to it.
 void openFrames(String dir)
          Open a frame sequencer using the given directory
 void remove(Agent newOne)
          Remove this actor from the agents list
 void run()
          Run for a default of 50 timesteps
 void run(int numSteps)
          Ask all agents to run for the number of input steps
 void setUp()
          setUp the simulation.
 String toString()
          Return a string with information on the number of agents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Simulation

public Simulation()
Constructor to set output to null


Simulation

public Simulation(Picture bg)
Constructor to set output to null

Method Detail

getWorld

public World getWorld()
Method to get the world


getOutput

public BufferedWriter getOutput()
Method to get the BufferedOutput to write to


getAgents

public LinkedList getAgents()
Get a linked list of all agents

Returns:
a linked list of all agent

add

public void add(Agent newOne)
Add this actor to the agents list

Parameters:
newOne - agent to add to the list

remove

public void remove(Agent newOne)
Remove this actor from the agents list

Parameters:
newOne - the agent to remove from the list

setUp

public void setUp()
setUp the simulation. Subclasses should call this (via super) and create agents.


openFile

public void openFile(String filename)
Open the input file and set the BufferedWriter to speak to it.

Parameters:
filename - the filename to open

openFrames

public void openFrames(String dir)
Open a frame sequencer using the given directory

Parameters:
dir - name of the directory

run

public void run(int numSteps)
Ask all agents to run for the number of input steps

Parameters:
numSteps - the number of timesteps to run

run

public void run()
Run for a default of 50 timesteps


endStep

public void endStep(int t)
End of step processing

Parameters:
t - the current timestep number

toString

public String toString()
Return a string with information on the number of agents. Will probably be overridden in subclsses.

Overrides:
toString in class Object
Returns:
the information string

closeFile

public void closeFile()
close the file and clear the output stream