MazeSolver

MazeSolver - / / / / / / / / / Assignment #: 11 Name:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Assignment #: 11 // Name: // StudentID: // Lecture: // Description: The MazeSolver contains two 2-dimetional character arrays, // one for the original and another to display the // solution to the maze, and the size of maze. // Its findSolution method solves the maze problem // and put the solution in the stack. import java.util.Stack; public class MazeSolver { private char[][] originalMaze; private char[][] maze; private int mazeSize; private Stack<Position> stackSoln; //Constructor to initialize the mazeSize, //initializes two 2-dimensional character arrays. public MazeSolver(String[] mazeInfo) { mazeSize = 10; setupMaze(mazeInfo); stackSoln = new Stack<Position>(); } //the setupMaze method initializes //two character arrays, using the input array of strings. public void setupMaze(String[] mazeInfo) { maze = new char[mazeSize][mazeSize]; originalMaze = new char[mazeSize][mazeSize]; for (int i=0; i<mazeSize; i++) { for (int j=0; j<mazeSize; j++) { originalMaze[i][j] = mazeInfo[i].charAt(j); maze[i][j] = originalMaze[i][j]; } } } //The displayPath methods returns a string describing //how to go from the starting position to the goal position
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

MazeSolver - / / / / / / / / / Assignment #: 11 Name:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online