Class BotWorld.Cell

java.lang.Object
  extended by BotWorld.Cell
Enclosing class:
BotWorld

public class BotWorld.Cell
extends Object

A class to represent an individual cell in (this) BotWorld, holding such attributes as number of dots present and whether the cell is a wall.


Constructor Summary
BotWorld.Cell(int x, int y)
          Create a new Cell at the given location in this BotWorld
 
Method Summary
 boolean addDot()
          Add a dot to this Cell.
 boolean addDots(int number)
          Add the specified number of dots to this Cell.
 void clear()
          Clear the contents of this cell: no dots, no walls.
 int getDots()
          Get the number of dots in this Cell.
 String getKey()
          Get the unique coordinate-based key for this Cell.
 BotWorld.Cell getNeighbor(char dir)
          Return this Cell's neighbor in the given direction, or null if no neighboring Cell object has been created.
 int getX()
          Get this Cell's x coordinate.
 int getY()
          Get this Cell's y coordinate.
 boolean hadWallUpdate()
          Find out whether this Cell's wall status (or that of one of its neighbors) has been updated since last checked (and therefore if its CellGraphic should update the connections to neighbors, for drawing).
 boolean hasDot()
          Find out whether this Cell has any dots.
 boolean isWall()
          Find out if this Cell is a wall (is impassable).
 boolean removeDot()
          Remove a dot from this Cell, assuming there is one to remove.
 void setWall(boolean isWall)
          Set whether this Cell is a wall (is impassable).
 void setWallUpdate()
          Set this Cell's wallUpdate status to true.
 String toString()
          Return a brief String description, like: Cell at (3, 5) with 4 dots and 1 thing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BotWorld.Cell

public BotWorld.Cell(int x,
                     int y)
Create a new Cell at the given location in this BotWorld

Parameters:
x - the x coordinate of this cell
y - the y coordinate of this cell
Method Detail

addDot

public boolean addDot()
Add a dot to this Cell. (Always succeeds.)

Returns:
true

addDots

public boolean addDots(int number)
Add the specified number of dots to this Cell. (Always succeeds.)

Parameters:
number - how many dots to add
Returns:
true

clear

public void clear()
Clear the contents of this cell: no dots, no walls. no things.


getDots

public int getDots()
Get the number of dots in this Cell.

Returns:
the number of dots this Cell has

getKey

public String getKey()
Get the unique coordinate-based key for this Cell.

Returns:
a String of the form "x, y"

getNeighbor

public BotWorld.Cell getNeighbor(char dir)
Return this Cell's neighbor in the given direction, or null if no neighboring Cell object has been created.

Parameters:
dir - the direction from which to fetch the neighbor
Returns:
the neighbor, or null if none exists

getX

public int getX()
Get this Cell's x coordinate.

Returns:
the x coordinate for this Cell

getY

public int getY()
Get this Cell's y coordinate.

Returns:
the y coordinate for this Cell

hadWallUpdate

public boolean hadWallUpdate()
Find out whether this Cell's wall status (or that of one of its neighbors) has been updated since last checked (and therefore if its CellGraphic should update the connections to neighbors, for drawing).

Returns:
true if this Cell's isWall status was changed since hadWallUpdate() was last called

hasDot

public boolean hasDot()
Find out whether this Cell has any dots.

Returns:
true if getDots() > 0, false otherwise

isWall

public boolean isWall()
Find out if this Cell is a wall (is impassable).

Returns:
true if this Cell is a wall, false otherwise

removeDot

public boolean removeDot()
Remove a dot from this Cell, assuming there is one to remove.

Returns:
true if a dot was removed, false otherwise

setWall

public void setWall(boolean isWall)
Set whether this Cell is a wall (is impassable).

Parameters:
isWall - whether this Cell (true) should be a wall or (false) should not be a wall

setWallUpdate

public void setWallUpdate()
Set this Cell's wallUpdate status to true.


toString

public String toString()
Return a brief String description, like: Cell at (3, 5) with 4 dots and 1 thing

Overrides:
toString in class Object