import java.util.*;

/**
 * A map of the tunnel system. Assume the data
 * has already had the single entrance converted
 * to 4 in this part. If not we'll need to do that
 * convrsion on the fly (TO DO).
 */

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

        createMap(input);
    }

    public Coordinate getEntrance()
    {
        return _entrance;
    }

    /**
     * Return the content of the Cell represented by the Coordinate.
     */

    public char getContent(Coordinate coord)
    {
        int index = _theMap.indexOf(new Cell(coord));
        Cell theCell = _theMap.get(index);

        return theCell.getContents(); // assume no error
    }

    /*
     * Is this Coordinate in range and can be moved into?
     */

    public boolean validPosition(Coordinate coord)
    {
        if ((coord.getX() >= 0) && (coord.getY() >= 0))
        {
            if ((coord.getX() < _maxX) && (coord.getY() < _maxY))
            {
                int index = _theMap.indexOf(new Cell(coord));

                if (index != -1) {
                    Cell theCell = _theMap.get(index);

                    if (theCell != null)
                        return !theCell.isWall();
                }
            }
        }

        return false;
    }

    public int numberOfKeys()
    {
        return _keys.size();
    }

    public int numberOfDoors()
    {
        return _doors.size();
    }

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

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

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

                index = 1;
            }
        }

        return str;
    }

    // create the map from input

    private void createMap(Vector<String> input)
    {
        Enumeration<String> iter = input.elements();
        int y = -1;

        _maxX = input.get(0).length(); // all lines are the same length (check?)

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

            String line = iter.nextElement();

            for (int x = 0; x < _maxX; x++)
            {
                Cell theCell = new Cell(new Coordinate(x, y), line.charAt(x));

                if (theCell.isEntrance())
                    _entrance = theCell.position(); // should be only one!
                else
                {
                    if (theCell.isKey())
                        _keys.add(theCell.getContents());
                    else
                    {
                        if (theCell.isDoor())
                            _doors.add(theCell.getContents());
                    }
                }

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

                _theMap.add(theCell);
            }
        }

        _maxY = y + 1;
    }

    private Vector<Cell> _theMap;
    private int _maxX;
    private int _maxY;
    private Coordinate _entrance;
    private Vector<Character> _keys;
    private Vector<Character> _doors;
    private boolean _debug;
}
@@ -236,16 +236,17 @@
 blic Map
+ 
 (Vector%3C
@@ -315,24 +315,71 @@
 or%3CCell%3E();%0A
+        _entrances = new Vector%3CCoordinate%3E();%0A
         _key
@@ -518,16 +518,23 @@
  public 
+Vector%3C
 Coordina
@@ -535,16 +535,17 @@
 ordinate
+%3E
  getEntr
@@ -548,16 +548,18 @@
 Entrance
+s 
 ()%0A    %7B
@@ -579,24 +579,25 @@
 rn _entrance
+s
 ;%0A    %7D%0A%0A   
@@ -705,16 +705,17 @@
 tContent
+ 
 (Coordin
@@ -999,16 +999,17 @@
 Position
+ 
 (Coordin
@@ -1515,16 +1515,17 @@
 erOfKeys
+ 
 ()%0A    %7B
@@ -1589,16 +1589,17 @@
 rOfDoors
+ 
 ()%0A    %7B
@@ -1676,16 +1676,17 @@
 toString
+ 
 ()%0A    %7B
@@ -2147,16 +2147,17 @@
 reateMap
+ 
 (Vector%3C
@@ -2656,19 +2656,22 @@
 entrance
- = 
+s.add(
 theCell.
@@ -2684,32 +2684,10 @@
 on()
+)
 ;
- // should be only one!
 %0A   
@@ -3281,16 +3281,23 @@
 private 
+Vector%3C
 Coordina
@@ -3298,16 +3298,17 @@
 ordinate
+%3E
  _entran
@@ -3309,16 +3309,17 @@
 entrance
+s
 ;%0A    pr

Update Map.java