maze
Class Maze
- public abstract class Maze
- implements Runnable
Title: Maze
Description: An abstract class that defines the maze interface
Copyright: Copyright (c) 2002
Company:
- Version:
- 1.0
- Author:
- Zoran Budimlic
window
MazeWindow window
- The corresponding View design patter for this maze
strategy
Strategy strategy
- The Strategy design patter for different operations on a maze
maze
Thread maze
- We have to run the maze in a thread to enable "animated" maze operations Don't worry about this
generateNewMaze
public static Maze generateNewMaze(int rows,
int cols,
MazeWindow window)
- A Factory method for generating a new maze. You should generate a new instance of your concrete class that implements the maze data structure here.
- Parameters:
rows
- Number of rows of the new maze
cols
- Number of coloumns of the new maze
window
- The MazeWindow that will draw this new maze to the user
- Returns:
- The newly generated maze
getStatus
public abstract Status getStatus(int x,
int y)
- Return the status of a cell in a maze. The following codes should be used for cell status: Status.NotVisited - the cell has not been visited Status.OnPath - the cell has been visited and it is on the currently researched path Status.Abandoned - the cell has been visited and it is abandoned as a possible path to the destination
- Parameters:
x
- The x coordinate of the cell in the maze
y
- The y coordinate of the cell in the maze
- Returns:
- The current status of the cell in question
setStatus
public abstract void setStatus(int x,
int y,
Status s)
- Set the status of a cell in a maze. The following codes should be used for cell status: Status.NotVisited - the cell has not been visited Status.OnPath - the cell has been visited and it is on the currently researched path Status.Abandoned - the cell has been visited and it is abandoned as a possible path to the destination
- Parameters:
x
- The x coordinate of the cell in the maze
y
- The y coordinate of the cell in the maze
s
- The current status of the cell in question
isThereAWall
public abstract boolean isThereAWall(int x1,
int y1,
int x2,
int y2)
- A query to tell whether there is a wall between two cells in a maze
- Parameters:
x1
-
x2
-
y1
-
y2
-
- Returns:
removeWall
public abstract void removeWall(int x1,
int y1,
int x2,
int y2)
- Remove a wall between two cells in a maze
- Parameters:
x1
-
y1
-
x2
-
y2
-
putWall
public abstract void putWall(int x1,
int y1,
int x2,
int y2)
- Put a wall between two cells in a maze
- Parameters:
x1
-
y1
-
x2
-
y2
-
clear
public abstract void clear()
- Clear the status of all maze cells. The status of all cells should be reset to Status.NotVisited
setStart
public abstract void setStart(int x,
int y)
- Set the coordinates of the starting point in the maze
- Parameters:
x
-
y
-
setEnd
public abstract void setEnd(int x,
int y)
- Set the coordinates of the end point in the maze
- Parameters:
x
-
y
-
startX
public abstract int startX()
- Returns:
- The X coordinate of the starting point
startY
public abstract int startY()
- Returns:
- The Y coordinate of the starting point
endX
public abstract int endX()
- Returns:
- The X coordinate of the end point
endY
public abstract int endY()
- Returns:
- The Y coordinate of the end point
rows
public abstract int rows()
- Returns:
- The number of rows in the maze
cols
public abstract int cols()
- Returns:
- The number of coloumns in the maze
pause
public synchronized void pause(int ms)
- A waiting routine. This is called whenever MazeWindow.repaintAndRefresh routine is called. Don't worry about this.
- Parameters:
ms
-
run
public synchronized void run()
- Run the apropriate strategy on this maze. Don't worry about this.
start
public synchronized void start()
- Start the maze thread. Don't worry about this.
stop
public synchronized void stop()
- Stop the maze thread. Don't worry about this