import java.util.*;

/**
 * A map of the tunnel system.
 */

public class Map
{
    public Map (Vector<String> input, boolean debug)
    {
        _theMap = new Vector<Cell>();
        _debug = debug;

        createMap(input);
    }

    @Override
    public String toString ()
    {
        Enumeration<Cell> iter = _theMap.elements();
        int index = 1;
        String str = "Map dimensions < "+_maxX+", "+_maxY+" >\n";

        while (iter.hasMoreElements())
        {
            str += iter.nextElement().getContents();

            if (index++ == _maxX)
            {
                str += "\n";

                index = 1;
            }
        }

        return str;
    }

    protected boolean valid (Coordinate coord)
    {
        if (coord != null)
        {
            if ((coord.getX() >= 0) && (coord.getY() >= 0))
            {
                if ((coord.getX() < _maxX) && (coord.getY() < _maxY))
                    return true;
            }
        }

        return false;
    }

    protected void createMapFromImage (String[] lines)
    {
        int lineLength = lines[0].length(); // all lines are the same length

        _maxY = lines.length -1;
        _maxX = lineLength;

        for (int y = 0; y < lines.length -1; y++)
        {
            for (int x = 0; x < lineLength; x++)
            {
                Cell theCell = new Cell(new Coordinate(x, y), String.valueOf(lines[y].charAt(x)), _debug);

                if (_debug)
                    System.out.println(theCell);

                _theMap.add(theCell);
            }
        }
    }

    protected Vector<Cell> _theMap;
    protected boolean _debug;
}
@@ -1045,22 +1045,28 @@
 ge (
-String%5B%5D lines
+Vector%3CString%3E input
 )%0A  
@@ -1098,16 +1098,20 @@
 h = 
-l
 in
-es%5B0%5D
+put.get(0)
 .len
@@ -1150,25 +1150,24 @@
  length%0A
-%0A
         
 _maxY = 
@@ -1162,41 +1162,82 @@
     
-_maxY
+Enumeration%3CString%3E iter
  = 
-l
 in
-es.length
+put.elements();%0A        int y =
  -1;%0A
+%0A
         
 _max
@@ -1236,88 +1236,113 @@
     
-_maxX = lineLength;%0A%0A        for (int y = 0; y %3C lines.length -1; y++)%0A        %7B
+while (iter.hasMoreElements())%0A        %7B%0A            y++;%0A%0A            String line = iter.nextElement();%0A
 %0A   
@@ -1374,22 +1374,25 @@
 x %3C line
-L
+.l
 ength
+()
 ; x++)%0A 
@@ -1485,17 +1485,16 @@
 eOf(line
-s
 %5By%5D.char

Update Map.java