Question
Need help with Java public void escapeFromMaze(MazePoint[][] maze) Youre given a maze in the form of a 2d-array of MazePoint objects. You start at the
Need help with Java public void escapeFromMaze(MazePoint[][] maze)
Youre given a maze in the form of a 2d-array of MazePoint objects. You start at the top left corner of this maze. You want to find a path to go to the bottom right corner of the maze, which is the exit. You can only go right OR go down. All the Xs in this 2d-array mean blockers, and all -s means empty spaces you can move to. There will always be a path to the exit and there will never be any forks or dead ends.
Your job is to trace out the path taken to solve the maze. Modify the maze in place. Youre required to record the position of each step you take on your way using an asterisk (*) to replace -s. For example, if you have the following input 2d array, that 2d array will become the output array after this method is running:
public boolean testEscape(MazePoint[][] maze, MazePoint[][] expectedSolution)
This function takes in two parameters - a 2-d array of MazePoint objects representing the test input (maze), and another 2-d array of MazePoint objects that represents the expected maze after solving the escape puzzle (expectedSolution). The function should run escapeFromMaze on maze, and verify that it matches expectedSolution. The function returns a boolean value - true if the expected array matches the array returned by escapeFromMaze, and false otherwise. If the test fails it should also print the expected solution maze and the actual maze produced by testEscape, along with an error message.
This function must handle edge conditions gracefully. For example, what would happen if the input maze is null, or if the number of rows and/or columns is less than one? For each of these cases, your method should not crash, but instead display an appropriate error message and return.
Thanks
xxx xxx xxx: xxxx * * * * xxx X X X input output xxx xxx xxx: xxxx * * * * xxx X X X input outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started