group1.model
Class EnvironmentGridSpace

java.lang.Object
  extended by group1.model.EnvironmentGridSpace

public class EnvironmentGridSpace
extends java.lang.Object

A space on the Environment grid. This contains a list of GameObj's at that location on the grid. This is not used to store the data directly. Rather, this is used to speed up computations, with the small overhead that the Environment class must keep the grid's object lists accurate.


Constructor Summary
EnvironmentGridSpace()
          Default constructor.
EnvironmentGridSpace(double x, double y, double side_length)
          Constructor.
 
Method Summary
 void addObject(GameObj object)
          Add an object to this grid space.
 int getNumObjects()
          Get the number of objects in this grid space.
 GameObj getObject(int i)
          Get the i'th object in this grid space.
 java.util.List<GameObj> getObjects()
          Get the list of objects in this grid space.
 XYPair getPosition()
          Get the position of this grid space.
 java.awt.geom.Rectangle2D getSquare()
          Directly get the rectangle representing this grid space.
 void removeObject(GameObj object)
          Remove an object from this grid space.
 void removeObject(int i)
          Remove the i'th object from this grid space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnvironmentGridSpace

public EnvironmentGridSpace()
Default constructor.


EnvironmentGridSpace

public EnvironmentGridSpace(double x,
                            double y,
                            double side_length)
Constructor.

Parameters:
x - The x-position.
y - The y-position.
side_length - The length of a side of the grid space square.
Method Detail

getObjects

public java.util.List<GameObj> getObjects()
Get the list of objects in this grid space.

Returns:
The list of objects here.

getObject

public GameObj getObject(int i)
Get the i'th object in this grid space.

Parameters:
i - The index of the object.
Returns:
The object with that index.

getNumObjects

public int getNumObjects()
Get the number of objects in this grid space.

Returns:
The number of objects here.

addObject

public void addObject(GameObj object)
Add an object to this grid space.

Parameters:
object - The object to be added.

removeObject

public void removeObject(GameObj object)
Remove an object from this grid space.

Parameters:
object - The object to be removed.

removeObject

public void removeObject(int i)
Remove the i'th object from this grid space.

Parameters:
i - The index of the object to be removed.

getPosition

public XYPair getPosition()
Get the position of this grid space.

Returns:
The position, represented as an x-y coordinate pair.

getSquare

public java.awt.geom.Rectangle2D getSquare()
Directly get the rectangle representing this grid space.

Returns:
The rectangle.