import java.util.*;
import java.io.*;

public class Maze
{
    public Maze (String data, boolean debug)
    {
        _theMaze = new Vector<Tile>();
        
        if (!loadData(data))
            System.out.println("Error in loading data file: "+data);

        _debug = debug;
    }

    public String toString ()
    {
        int xAxis = 0;
        Enumeration<Tile> iter = _theMaze.elements();
        String str = "";

        while (iter.hasMoreElements())
        {
            Tile theEntry = iter.nextElement();

            if (theEntry.position().getX() != xAxis)
            {
                xAxis = theEntry.position().getX();
                str += "\n";
            }

            str += theEntry.toString();
        }

        return str;
    }
    
    private final boolean loadData (String file)
    {
        BufferedReader reader = null;
        boolean valid = true;

        try
        {
            reader = new BufferedReader(new FileReader(file));
            String line = null;

            while ((line = reader.readLine()) != null)
            {
                char[] asChar = line.toCharArray();  // all lines are the same length
                
                if (_width == 0)
                    _width = asChar.length;

                for (int i = 0; i < _width; i++)
                {
                    switch (asChar[i])
                    {
                        case TileId.WALL:
                        case TileId.SPACE:
                        case TileId.PASSAGE:
                            _theMaze.add(new Tile(new Coordinate(i, _height), asChar[i]));
                        default:
                            _theMaze.add(new Tile(new Coordinate(i, _height), TileId.SPACE));
                    }
                }

                _height++;
            }
        }
        catch (Throwable ex)
        {
            valid = false;

            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }

        return valid;
    }

    private Vector<Tile> _theMaze;
    private int _height = 0;
    private int _width = 0;
    private boolean _debug;
}
@@ -142,24 +142,16 @@
 ile%3E();%0A
-        
 %0A       
@@ -313,31 +313,8 @@
   %7B%0A
-        int xAxis = 0;%0A
     
@@ -385,17 +385,70 @@
  str = %22
-%22
+Maze %3C %22+_width+%22, %22+_height+%22 %3E%5Cn%22;%0A        int y = 0
 ;%0A%0A     
@@ -552,20 +552,23 @@
         
-if (
+str += 
 theEntry
@@ -572,35 +572,20 @@
 try.
-position().getX() != xAxis)
+toString();%0A
 %0A   
@@ -585,33 +585,37 @@
 );%0A%0A            
-%7B
+y++;%0A
 %0A               
@@ -615,47 +615,24 @@
     
-    xAxis = theEntry.position().getX();
+if (y == _width)
 %0A   
@@ -644,25 +644,14 @@
     
+%7B%0A
     
-str += %22%5Cn%22;%0A
     
@@ -650,35 +650,43 @@
                 
-%7D%0A%0A
+y = 0;%0A    
             str 
@@ -688,36 +688,35 @@
  str += 
-theEntry.toString();
+%22%5Cn%22;%0A            %7D
 %0A       
@@ -1587,24 +1587,59 @@
 sChar%5Bi%5D));%0A
+                            break;%0A
             
@@ -1749,24 +1749,59 @@
 Id.SPACE));%0A
+                            break;%0A
             

Update Maze.java