Class WorldGrid

java.lang.Object
  |
  +--WorldGrid

public final class WorldGrid
extends java.lang.Object

This class provides a representation for the simulation (World)


Method Summary
 Animal getElem(int x, int y)
          observer of elements of WorldGrid
 Animal getElem(Location loc)
          observer of elements of WorldGrid
 LocationObjectPair getGridElement(Location loc)
          observer of WorldGrid;
 void setElem(int x, int y, Animal obj)
          mutator of WorldGrid; stores reference to object obj at location x,y
 void setElem(Location loc, Animal obj)
          mutator of WorldGrid; stores reference to object obj at Location loc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getElem

public final Animal getElem(Location loc)
observer of elements of WorldGrid
Parameters:
loc - is location whose occupant is requested
Returns:
reference to Animal at Location loc; can be null

getElem

public final Animal getElem(int x,
                            int y)
observer of elements of WorldGrid
Parameters:
x - is x co-ord of location whose occupant is requested
y - is y co-ord of location whose occupant is requested
Returns:
reference to Animal at location x,y; can be null

setElem

public final void setElem(Location loc,
                          Animal obj)
mutator of WorldGrid; stores reference to object obj at Location loc
Parameters:
loc - is location to be wrapped
obj - is Animal reference to be stored at wrapped location

setElem

public final void setElem(int x,
                          int y,
                          Animal obj)
mutator of WorldGrid; stores reference to object obj at location x,y
Parameters:
x - is x co-ordinate of location
y - is y co-ordiante of location
obj - is reference to be stored at location

getGridElement

public final LocationObjectPair getGridElement(Location loc)
observer of WorldGrid;
Parameters:
loc - is location in simulation
Returns:
returns LocationObjectPair built from Animal at loc and Location loc