import java.util.*;

/**
 * Take an image from the camera and turn it into a map
 * which can be used to move around.
 */

public class Map
{
    public Map (Image img, boolean debug)
    {
        _theMap = new Vector<Cell>();
        _maxX = 0;
        _maxY = 0;
        _originalImage = img;
        _debug = debug;

        createMapFromImage(img.scannedLines());
    }

    public Map (Map toCopy)
    {
        _theMap = new Vector<Cell>();
        _maxX = 0;
        _maxY = 0;
        _originalImage = toCopy._originalImage;
        _debug = toCopy._debug;

        createMapFromImage(_originalImage.scannedLines());
    }

    public Coordinate findStartingPoint ()
    {
        Enumeration<Cell> iter = _theMap.elements();

        while (iter.hasMoreElements())
        {
            Cell cur = iter.nextElement();

            if (cur.getContents().equals(CellId.ROBOT_FACING_UP))
                return cur.position();
        }

        return null;
    }

    public boolean isScaffold (Coordinate coord)
    {
        Cell temp = new Cell(coord);
        int index = _theMap.indexOf(temp);

        temp = _theMap.get(index);

        return (temp.getContents().equals(CellId.SCAFFOLDING));
    }

    public void changeElement (Coordinate coord, String type)
    {
        Cell temp = new Cell(coord);
        int index = _theMap.indexOf(temp);

        temp = _theMap.get(index);

        temp.setContents(type);
    }

    @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;
    }

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

        _maxY = lines.length;
        _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);
            }
        }
    }

    private Vector<Cell> _theMap;
    private int _maxX;
    private int _maxY;
    private Image _originalImage;
    private boolean _debug;
}
@@ -1213,232 +1213,8 @@
  %7D%0A%0A
-    public void changeElement (Coordinate coord, String type)%0A    %7B%0A        Cell temp = new Cell(coord);%0A        int index = _theMap.indexOf(temp);%0A%0A        temp = _theMap.get(index);%0A%0A        temp.setContents(type);%0A    %7D%0A%0A
     
@@ -1223,16 +1223,16 @@
 verride%0A
+
     publ
@@ -1668,21 +1668,23 @@
 %0A%0A    pr
-ivate
+otected
  void cr
@@ -2244,21 +2244,188 @@
 %0A%0A    pr
-ivate
+otected Map ()%0A    %7B%0A        _theMap = new Vector%3CCell%3E();%0A        _maxX = 0;%0A        _maxY = 0;%0A        _originalImage = null;%0A        _debug = false;%0A    %7D%0A%0A    protected
  Vector%3C
@@ -2437,37 +2437,39 @@
  _theMap;%0A    pr
-iva
+otec
 te
+d
  int _maxX;%0A    
@@ -2470,21 +2470,23 @@
 ;%0A    pr
-iva
+otec
 te
+d
  int _ma
@@ -2495,21 +2495,23 @@
 ;%0A    pr
-iva
+otec
 te
+d
  Image _
@@ -2535,13 +2535,15 @@
   pr
-ivate
+otected
  boo

Update Map.java