|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMaze
public class Maze
The Maze class represents a maze constructed as a rectangle of square cells (each of which is represented by a MazeCell class). We create Mazes using the nested class MazeFactory and solve Mazes using instances of the MazeRunner abstract class.
Nested Class Summary | |
---|---|
static class |
Maze.MazeFactory
MazeFactory is a Factory Design Pattern that generates a new Maze. |
private class |
Maze.MazeIterator
An iterator class that iterates over all the cells in a Maze. |
private class |
Maze.NeighborIterator
An iterator class that iterates over all neighbors that can be reached from the cell the iterator was created for. |
Field Summary | |
---|---|
private MazeCell[][] |
cells
A 2-dimensional array that holds/represents all the cells in this maze. |
private MazeCell |
donutCell
The donut cell of this maze. |
private int |
height
The height of the maze |
private java.util.ArrayList<MazeChangeListener> |
mazeChangeListeners
A list of the MazeChangeListener s that will be notified on
a visitation state change. |
private MazeCell |
startCell
The start cell of this maze. |
private int |
width
The width of the maze |
Constructor Summary | |
---|---|
private |
Maze()
Create an incomplete Maze. |
Method Summary | |
---|---|
void |
addMazeChangeListener(MazeChangeListener listener)
Adds a new MazeChangeListener to listen to changes in this maze. |
MazeCell |
getCell(int row,
int col)
Returns the cell located at (row,col). |
java.util.Iterator<MazeCell> |
getCells()
Returns an iterator over all cells in this maze. |
MazeCell |
getDonut()
Return the maze cell that contains the donut. |
int |
getHeight()
Get the height, in number of cells, of the maze. |
java.util.Iterator<MazeCell> |
getNeighbors(MazeCell cell)
Returns an iterator over the neighbors of the given cell. |
MazeCell |
getStart()
Return the maze's starting cell. |
int |
getWidth()
Get the width, in number of cells, of the maze. |
private void |
setCell(int row,
int col,
MazeCell cell)
Change the cell located at (row,col). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private MazeCell startCell
private MazeCell donutCell
private MazeCell[][] cells
private int width
private int height
private java.util.ArrayList<MazeChangeListener> mazeChangeListeners
MazeChangeListener
s that will be notified on
a visitation state change.
Constructor Detail |
---|
private Maze()
Method Detail |
---|
public void addMazeChangeListener(MazeChangeListener listener)
listener
- listener to add to the maze's set of change listenerspublic MazeCell getStart()
public MazeCell getDonut()
public java.util.Iterator<MazeCell> getCells()
public java.util.Iterator<MazeCell> getNeighbors(MazeCell cell)
cell
- the cell whose neighbors should be returned.
public MazeCell getCell(int row, int col)
row
- The row of the cell to retrieve.col
- The column of the cell to retrieve.
private void setCell(int row, int col, MazeCell cell)
row
- The row of the cell to set.col
- The column of the cell to set.public int getWidth()
public int getHeight()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |