/*
 * the maze contains squares that are clear, walls, path to exit and visited 
 * but not in final path
 * marsh Poulson 9/26/2013
 */
package poulproj05;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.imageio.IIOException;

/*
 * The class maze represents a maze and internally stores values for each of its squares
 */
public class Maze {
    public static final char CLEAR = ' ', WALL = 'x', CREATURE = 'o', VISTITED = 'v', PATH = 'p';
    private char[][] maze_;
    private Creature creature_;
    private int startX, startY, endX, endY;
    private final int height, width;
    
    /*
     * returns the height of the maze
     */
    public int getHeight()
    {
        return height;
    }
    /*
     * returns the width of the maze
     */
    public int getWidth()
    {
        return width;
    }
    /*
     * returns the x value of the starting location
     */
    public int getStartX()
    {
        return startX;
    }
    /*
     * returns the y value for the starting position 
     */
    public int getStartY()
    {
        return startY;
    }
    /*
     * mark position x, y as visited 
     */
    public void markVisited(int x, int y)
    {
        maze_[x][y] = Maze.VISTITED;
    }
    /*
     * Mark the position x, y as the path
     */
    public void markPath(int x, int y)
    {
        maze_[x][y] = Maze.PATH;
    }
    /*
     * Instantiated a maze from a given file throws exceptions if the file
     * is not in the correct format
     */
    public Maze(String file) throws FileNotFoundException, IOException
    {
        BufferedReader fileIn = new BufferedReader(new FileReader(file));
        String heightWidth = fileIn.readLine();
        String[] hw = heightWidth.split(" ");
        if(hw.length != 2)
        {
            throw new IIOException("file is not of the correct format");
        }
        height = Integer.parseInt(hw[0]);
        width = Integer.parseInt(hw[1]);
        
        maze_ = new char[height][width];
        
        //get exit from file
        String[] exit = fileIn.readLine().split(" ");
        if(exit.length != 2)
        {
            throw new IIOException("file is not of the correct format");
        }
        endX = Integer.parseInt(exit[0]);
        endY = Integer.parseInt(exit[1]);
        
        //get start from file
        String[] start = fileIn.readLine().split(" ");
        if(start.length != 2)
        {
            throw new IIOException("file is not of the correct format");
        }
        startX = Integer.parseInt(start[0]);
        startY = Integer.parseInt(start[1]);
        
        //now read in values
        for(int i= 0; i < height; i++)
        {
            String line = fileIn.readLine();
            for(int k=0; k< width; k++)
            {
                maze_[i][k] = line.charAt(k);
                //verify value here
                
                
            }
        }
        fileIn.close();
    }
    /*
     * returns whether or not a square is clear given by x, y
     */
    public boolean isClear(int x , int y)
    {
        if(maze_[x][y] == CLEAR)
            return true;
        return false;
    }
    /*
     * returns true if the coordinates x, y are the exit
     */
    public boolean atExit(int x, int y)
    {
        if(endX == x && endY == y)
        {
            return true;
        }
        return false;
    }
}

@@ -3018,24 +3018,74 @@
 In.close();%0A
+        creature_ = new Creature(startX, startY);%0A
     %7D%0A    /*
@@ -3515,10 +3515,444 @@
 ;%0A    %7D%0A
+    %0A    @Override public String toString()%0A    %7B%0A        String returnMe = new String();%0A        for(int i=0; i %3C height; i++)%0A        %7B%0A            for(int k=0; k %3C width; k++)%0A            %7B%0A                returnMe = returnMe + maze_%5Bi%5D%5Bk%5D;%0A            %7D%0A            returnMe = returnMe + %22%5Cn%22;%0A        %7D%0A        return returnMe;%0A    %7D%0A    public boolean runCreature()%0A    %7B%0A        return Creature.goNorth(this, creature_);%0A    %7D%0A
 %7D%0A

Update Maze.java