Question: Howdy, please help me with this question in JAVA, I have to use both EmptyStackException and GoodStack, thats why I put it up there, if

 Howdy, please help me with this question in JAVA, I have

to use both EmptyStackException and GoodStack, thats why I put it up

there, if you have any question about the question itself, please comment

and I will answer it! Thank you! In this assignment you are

to write a program that finds a path through a "maze". The

maze will be represented by a 2-dimensional array of ints. You will

Howdy, please help me with this question in JAVA, I have to use both EmptyStackException and GoodStack, thats why I put it up there, if you have any question about the question itself, please comment and I will answer it! Thank you!

In this assignment you are to write a program that finds a path through a "maze". The maze will be represented by a 2-dimensional array of ints. You will be given a starting point in the array that consists of a pair of ints . In this pair, x represents the row coordinate of the starting cell and y represents the column coordinate of the starting cell Given a starting coordinate , your program will construct a sequence of coordinates (beginning with ) that represents the path through the maze. As an example, consider the following maze that has a starting coordinate of . An entry of 5 in this maze represents "solid rock" and you cannot "visit" a cell with that value. An entry of 0 in this array represents a cell that you can "visi" 000 005 5 50 505 5 50 55 5 500 0 00 A successful run of your program with this array as input would thus output the sequence Your program will solve a maze problem by using a stack to keep track of those cells that have already been visited. Your program should thus proceed as follows: 1. Change the value of the starting cell from a 0 to a 1. Make an instance of the Coordinate class that corresponds to the starting cell and push it onto the stack. This coordinate represents the starting or "current" cell. It's the place at which you enter the maze Do a clockwise search for the next cell to be visited. For a given cell there are at most 3 possibilities for "new" cells to be visited. Once a "new" cell has been found push a coordinate instance with the cell's coordinates onto the stack and change the value in that cell from a 0 to a 1. That cell becomes the "current cell". If no "new" cell can be found, then you are at a dead end and must backtrack. Note that no "new" cell can be found if the only cell(s) found has (have) a value of1. Backtracking is accomplished by popping the stack and designating the "current" cell as the one whose coordinate values match the values of the Coordinate instance on the top of the stack. When a search for the next cell to be visited after the "current cell" yields coordinate values that are outside the array, you are done. Note that if the entry cell is in the first row, your search will automatically take you outside the array. Thus, you must treat the entry cell as a 2. In this assignment you are to write a program that finds a path through a "maze". The maze will be represented by a 2-dimensional array of ints. You will be given a starting point in the array that consists of a pair of ints . In this pair, x represents the row coordinate of the starting cell and y represents the column coordinate of the starting cell Given a starting coordinate , your program will construct a sequence of coordinates (beginning with ) that represents the path through the maze. As an example, consider the following maze that has a starting coordinate of . An entry of 5 in this maze represents "solid rock" and you cannot "visit" a cell with that value. An entry of 0 in this array represents a cell that you can "visi" 000 005 5 50 505 5 50 55 5 500 0 00 A successful run of your program with this array as input would thus output the sequence Your program will solve a maze problem by using a stack to keep track of those cells that have already been visited. Your program should thus proceed as follows: 1. Change the value of the starting cell from a 0 to a 1. Make an instance of the Coordinate class that corresponds to the starting cell and push it onto the stack. This coordinate represents the starting or "current" cell. It's the place at which you enter the maze Do a clockwise search for the next cell to be visited. For a given cell there are at most 3 possibilities for "new" cells to be visited. Once a "new" cell has been found push a coordinate instance with the cell's coordinates onto the stack and change the value in that cell from a 0 to a 1. That cell becomes the "current cell". If no "new" cell can be found, then you are at a dead end and must backtrack. Note that no "new" cell can be found if the only cell(s) found has (have) a value of1. Backtracking is accomplished by popping the stack and designating the "current" cell as the one whose coordinate values match the values of the Coordinate instance on the top of the stack. When a search for the next cell to be visited after the "current cell" yields coordinate values that are outside the array, you are done. Note that if the entry cell is in the first row, your search will automatically take you outside the array. Thus, you must treat the entry cell as a 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!