Class MazeSolver

java.lang.Object
  extended by MazeSolver

public class MazeSolver
extends java.lang.Object


Field Summary
(package private)  java.io.File file
           
(package private)  int height
           
(package private)  Maze maze
           
(package private)  java.util.Stack<Vertex> path
           
(package private)  java.util.Scanner scan
           
(package private)  int width
           
 
Constructor Summary
MazeSolver(java.io.File file)
          Constructor initializes width, height, scanner, and maze.
MazeSolver(Maze maze)
          Given a maze, calls solveMaze()
 
Method Summary
 void fillMaze()
          Reads in pairs of vertices from the file (passed into scan in the constructor) to build up the maze.
 Maze getMaze()
           
static void printPath(java.util.Stack<Vertex> stack)
          The stack contains the path in reverse order, so pop into another stack, then pop and print.
 void solveMaze()
          Find and print the shortest path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

int width

height

int height

maze

Maze maze

path

java.util.Stack<Vertex> path

file

java.io.File file

scan

java.util.Scanner scan
Constructor Detail

MazeSolver

public MazeSolver(java.io.File file)
           throws java.io.FileNotFoundException
Constructor initializes width, height, scanner, and maze. Calls fillMaze() to create the maze.

Parameters:
file - The file to scan from
Throws:
java.io.FileNotFoundException

MazeSolver

public MazeSolver(Maze maze)
Given a maze, calls solveMaze()

Parameters:
maze - The maze to be solved
Method Detail

fillMaze

public void fillMaze()
Reads in pairs of vertices from the file (passed into scan in the constructor) to build up the maze.


getMaze

public Maze getMaze()
Returns:
This instance's maze

solveMaze

public void solveMaze()
Find and print the shortest path


printPath

public static void printPath(java.util.Stack<Vertex> stack)
The stack contains the path in reverse order, so pop into another stack, then pop and print.

Parameters:
stack - The vertices of the path