Class MazeCell

java.lang.Object
  extended by MazeCell

public class MazeCell
extends java.lang.Object

The MazeCell class stores information about each individual cell in the maze. The boolean values north, east, west, and south store which walls are up; e.g., if north is true, then the north wall is up. Each cell also has pointer to its four MazeCell neighbors, neighborN, neighborE, neighborS, and neighborW. If any of these values are null, it means this cell is on the border of the maze.


Constructor Summary
MazeCell()
          Sets all the walls to true and initializes the random number generator.
 
Method Summary
 boolean east()
          Returns whether or not this cell has its east wall up.
 void examine()
          Sets the examined flag to true.
 boolean examined()
          Returns whether or not this cell has been examined.
 MazeCell[] getNeighbors()
          Gets the neighbors of this cell.
 boolean hasAllWalls()
          Returns whether or not this cell has all its walls up.
 boolean north()
          Returns whether or not this cell has its north wall up.
 void setNeighbors(MazeCell n, MazeCell e, MazeCell s, MazeCell w)
          Sets the pointers to the neighbors of this cell.
 void setWalls(boolean north, boolean east, boolean south, boolean west)
          Sets whether or not there are walls up to the north, east, south, and west of this cell.
 boolean south()
          Returns whether or not this cell has its south wall up.
 void visit()
          Sets the visited flag to true.
 boolean visited()
          Returns whether or not this cell has been visited.
 boolean west()
          Returns whether or not this cell has its west wall up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MazeCell

public MazeCell()
Sets all the walls to true and initializes the random number generator.

Method Detail

visit

public void visit()
Sets the visited flag to true.


visited

public boolean visited()
Returns whether or not this cell has been visited.

Returns:
true if the cell has been visited.

examine

public void examine()
Sets the examined flag to true.


examined

public boolean examined()
Returns whether or not this cell has been examined.

Returns:
true if the cell has been examined.

setNeighbors

public void setNeighbors(MazeCell n,
                         MazeCell e,
                         MazeCell s,
                         MazeCell w)
Sets the pointers to the neighbors of this cell. If a pointer is null, that means this cell is along the border of the maze.

Parameters:
n - The north neighbor of this cell.
e - The east neighbor of this cell.
s - The south neighbor of this cell.
w - The west neighbor of this cell.

setWalls

public void setWalls(boolean north,
                     boolean east,
                     boolean south,
                     boolean west)
Sets whether or not there are walls up to the north, east, south, and west of this cell.

Parameters:
north - true if there's a wall on the north side of the cell.
east - true if there's a wall on the east side of the cell.
south - true if there's a wall on the south side of the cell.
west - true if there's a wall on the west side of the cell.

hasAllWalls

public boolean hasAllWalls()
Returns whether or not this cell has all its walls up.

Returns:
true if all walls are up.

north

public boolean north()
Returns whether or not this cell has its north wall up.

Returns:
true if the cell's north wall is up.

south

public boolean south()
Returns whether or not this cell has its south wall up.

Returns:
true if the cell's south wall is up.

east

public boolean east()
Returns whether or not this cell has its east wall up.

Returns:
true if the cell's east wall is up.

west

public boolean west()
Returns whether or not this cell has its west wall up.

Returns:
true if the cell's west wall is up.

getNeighbors

public MazeCell[] getNeighbors()
Gets the neighbors of this cell. Returns an array of those neighbors. The length of the array is the number of neighbors this cell has.

Returns:
An array with the neighbors contained within it.