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 (Vector<String> input)
    {
        int lineLength = input.get(0).length(); // all lines are the same length
        Enumeration<String> iter = input.elements();
        int y = -1;

        while (iter.hasMoreElements())
        {
            y++;

            String line = iter.nextElement();

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

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

                _theMap.add(theCell);
            }
        }
    }

    protected Vector<Cell> _theMap;
    protected boolean _debug;
}
@@ -223,24 +223,26 @@
 put);%0A    %7D%0A
+/*
 %0A    @Overri
@@ -382,49 +382,8 @@
  = %22
-Map dimensions %3C %22+_maxX+%22, %22+_maxY+%22 %3E%5Cn
 %22;%0A%0A
@@ -644,329 +644,10 @@
    %7D
-%0A%0A    protected boolean valid (Coordinate coord)%0A    %7B%0A        if (coord != null)%0A        %7B%0A            if ((coord.getX() %3E= 0) && (coord.getY() %3E= 0))%0A            %7B%0A                if ((coord.getX() %3C _maxX) && (coord.getY() %3C _maxY))%0A                    return true;%0A            %7D%0A        %7D%0A%0A        return false;%0A    %7D
+*/
 %0A%0A  
@@ -676,17 +676,8 @@
 eMap
-FromImage
  (Ve
@@ -1103,30 +1103,12 @@
 y), 
-String.valueOf(
 line
-%5By%5D
 .cha
@@ -1113,17 +1113,16 @@
 harAt(x)
-)
 , _debug

Update Map.java