Your task is to find the path to the upper left corner, the green grid, from any possible point in the maze, like this:
Maze.java API:
Constructor: Maze(int rows, int columns)
Generates a maze of size rows x columns. A typical size would be 60x80. Bigger values tend to be critical due to stack overflow.
The constructor also DISPLAYS the maze in its own window. A button is implemented to change the maze's topology.
Method Byte getMazeData(int row, int col)
returns the value of the chamber, coordinates (row, col) (NOT x,y !). The value encodes the presence of walls of the chamber in the lower 4 bits:
bit 0 set: north wall present
bit 1 set: west wall present
bit 2 set: south wall present
bit 3 set: east wall present
bit 5 (not 4) is used to mark the exit, the upper left corner. if you want to check if you found the exit, you can either check for this bit or for
row/column 0/0.
Example: a chamber having walls north and west would return the value 3, for '000000011'. The top left chamber (the exit chamber) in image 2 has the
value '00101011' = 43.
public void showPath(Iterator path)
used to display the computed path, shown as red rectangles, see image 2. A path is passed to the method by an iterator. The elements
in the iterated structure must be of type java.awt.Point. This is a class that contains only two fields, x and y. Please put the row into X,
the column into Y (this is unconventional. read it again !).
Method void addMazeListener(MazeListener ml)
The maze window is clickable, i.e. if you click on a chamber in the maze, you can get the coordinates of the clicked chamber.
In order to do so, you have to implement the Interface 'MazeListener' in your program (the interface is explained below). As soon as you
register your class to the Maze, using addMazeListener, it is able to receive the coordinates of the clicked chamber.
Note: although the implementation of Maze is not of specific interest to this assignment, i should be mentioned that the graphical output of the
maze does not consist of a grid of JButtons. This would be a GUI overkill.
Interface MazeListener
The interface has only a single method:
public void MazeClicked(int row, int col)
This method is called as soon as a chamber in the maze is clicked. row and col are the coordinates of the chamber.