Generalize methods mazeTraversal and mazeGenerator of earlier exercises to process mazes of any width and height.


Answered 7 months ago
Answered 7 months ago
Step 1
1 of 4

In the code given below, the classes Maze and MazeGenerator are made more robust and able to handle mazes of any user-defined size. In the main method, a 5 x 10 maze is randomly generated and tested upon. Note that the commented out code can be used for understanding the control flow during code execution and also for debugging.

Note the use of length attribute in the two-dimensional arrays. The first element of the 2D array maze is an array. Hence, maze[0] is the array representing the first row of the maze. Each element of this array is a row array. Hence, maze[0].length represents the width of the array and maze.length represents the height of the array.

Create an account to view solutions

Create an account to view solutions

More related questions