Class Landscape

java.lang.Object
  extended by Landscape

public class Landscape
extends Object

Represents a continuous landscape with agents moving on it. The class handles advancing the simulation, identifying neighbors of a given cell, and adding and removing agents (Cell child classes).


Field Summary
private  MyLinkedList<Cell> agents
          List of Cell agents on the landscape
private  double height
          Height of the landscpe
private  double width
          Width of the landscpe
 
Constructor Summary
Landscape(double rows, double cols)
          Alternate Constructor using doubles
Landscape(int rows, int cols)
          Constructor
 
Method Summary
 void addAgent(Cell a)
          Adds an agent to the Landscape
 void advance()
          Advances the Landsacpe one turn of the simulation.
 ArrayList<Cell> getAgents()
          Returns an ArrayList of the agents in a Landscape
 int getCols()
          Returns the width of the Landscape in units
 double getHeight()
          Returns the height of the Landscape in units
 ArrayList<Cell> getNeighbors(Cell qcell)
          Returns the neighbors of the query Cell
 int getRows()
          Returns the height of the Landscape in units
 double getWidth()
          Returns the width of the Landscape in units
static void main(String[] argv)
          Test function
 void removeAgent(Cell a)
          Removes an agent from the Landscape
 void reset()
          Clears all agents from the Landscape
 String toString()
          Returns a string representation of the Landscape
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

width

private double width
Width of the landscpe


height

private double height
Height of the landscpe


agents

private MyLinkedList<Cell> agents
List of Cell agents on the landscape

Constructor Detail

Landscape

public Landscape(int rows,
                 int cols)
Constructor

Parameters:
rows - the height of the Landscape in units
cols - the width of the Landscape in units

Landscape

public Landscape(double rows,
                 double cols)
Alternate Constructor using doubles

Parameters:
rows - the height of the Landscape in units
cols - the width of the Landscape in units
Method Detail

reset

public void reset()
Clears all agents from the Landscape


getRows

public int getRows()
Returns the height of the Landscape in units


getHeight

public double getHeight()
Returns the height of the Landscape in units


getCols

public int getCols()
Returns the width of the Landscape in units


getWidth

public double getWidth()
Returns the width of the Landscape in units


addAgent

public void addAgent(Cell a)
Adds an agent to the Landscape

Parameters:
a - the agent to add to the Landscape

removeAgent

public void removeAgent(Cell a)
Removes an agent from the Landscape

Parameters:
a - the agent to remove from the Landscape

getAgents

public ArrayList<Cell> getAgents()
Returns an ArrayList of the agents in a Landscape


toString

public String toString()
Returns a string representation of the Landscape

Overrides:
toString in class Object

getNeighbors

public ArrayList<Cell> getNeighbors(Cell qcell)
Returns the neighbors of the query Cell

Parameters:
qcell - the Cell whose neighbors should be returned

advance

public void advance()
Advances the Landsacpe one turn of the simulation. Uses a shuffled list of agents so the update order is randomized each turn.


main

public static void main(String[] argv)
Test function

Parameters:
argv - list of strings from the command line