import java.util.*;

public class Scaffold
{
    public static final String SCAFFOLDING = "#";
    public static final String OPEN_SPACE = ".";

    // ASCII codes.

    public static final String SCAFFOLDING_CODE = "35";
    public static final String OPEN_SPACE_CODE = "46";
    public static final String NEW_LINE_CODE = "10";

    public Scaffold (boolean debug)
    {
        _image = new Vector<String>();
        _numberOfLines = 0;
        _debug = debug;
    }

    public void addData (String value)
    {
        if ((SCAFFOLDING_CODE.equals(value)) || (OPEN_SPACE_CODE.equals(value)) || (NEW_LINE_CODE.equals(value)))
        {
            _image.add(value);

            if (NEW_LINE_CODE.equals(value))
                _numberOfLines++;
        }
        else
        {
            if (VacuumRobot.isRobotCode(value))
                _image.add(value);
            else
            {
                if (_debug)
                    System.out.println("Invalid code: "+value);
            }
        }
    }

    public void scanForIntersections ()
    {
        int sizeOfLines = numberOfLineElements();
        String[][] lines = new String[_numberOfLines][sizeOfLines];
        int lineNumber = 0;
        Enumeration<String> iter = _image.elements();

        while (lineNumber < _numberOfLines)
        {
            int lineEntry = 0;
        }
    }

    @Override
    public String toString ()
    {
        Enumeration<String> iter = _image.elements();
        String str = "";

        while (iter.hasMoreElements())
        {
            String val = iter.nextElement();

            switch (val)
            {
                case SCAFFOLDING_CODE:
                {
                    str += SCAFFOLDING;
                }
                break;
                case OPEN_SPACE_CODE:
                {
                    str += OPEN_SPACE;
                }
                break;
                case NEW_LINE_CODE:
                {
                    str += "\n";
                }
                break;
                default:
                    str += VacuumRobot.print(val);
            }
        }

        return str;
    }

    private final int numberOfLineElements ()
    {
        int sizeOfLines = 0;
        Enumeration<String> iter = _image.elements();
        boolean done = false;

        while (iter.hasMoreElements() && !done)
        {
            sizeOfLines++;

            String entry = iter.nextElement();

            if (NEW_LINE_CODE.equals(entry))
                done = true;
        }

        return sizeOfLines;
    }

    private Vector<String> _image;
    private int _numberOfLines;
    private boolean _debug;
}
@@ -1072,45 +1072,36 @@
     
-int sizeOfLines = numberOfLineElement
+String%5B%5D lines = scannedLine
 s();
@@ -1109,248 +1109,386 @@
     
+%7D%0A%0A
     
-String%5B%5D%5B%5D lines = new String%5B_numberOfLines%5D%5BsizeOfLines%5D;%0A        int lineNumber = 0;%0A        Enumeration%3CString%3E iter = _image.elements();%0A%0A        while (lineNumber %3C _numberOfLines)%0A        %7B%0A            int lineEntry = 0;%0A
+@Override%0A    public String toString ()%0A    %7B%0A        Enumeration%3CString%3E iter = _image.elements();%0A        String str = %22%22;%0A%0A        while (iter.hasMoreElements())%0A        %7B%0A            String val = iter.nextElement();%0A%0A            switch (val)%0A            %7B%0A                case SCAFFOLDING_CODE:%0A                %7B%0A                    str += SCAFFOLDING;%0A      
         
 %7D%0A  
@@ -1487,66 +1487,522 @@
     
+  
 %7D%0A    
-%7D%0A%0A    @Override%0A    public String toString ()%0A    %7B
+            break;%0A                case OPEN_SPACE_CODE:%0A                %7B%0A                    str += OPEN_SPACE;%0A                %7D%0A                break;%0A                case NEW_LINE_CODE:%0A                %7B%0A                    str += %22%5Cn%22;%0A                %7D%0A                break;%0A                default:%0A                    str += VacuumRobot.print(val);%0A            %7D%0A        %7D%0A%0A        return str;%0A    %7D%0A%0A    private String%5B%5D scannedLines ()%0A    %7B%0A        String%5B%5D lines = new String%5B_numberOfLines%5D;
 %0A   
@@ -2044,32 +2044,60 @@
 age.elements();%0A
+        int lineNumber = 0;%0A
         String s
@@ -2191,32 +2191,71 @@
 r.nextElement();
+%0A            boolean endOfLine = false;
 %0A%0A            sw
@@ -2623,39 +2623,74 @@
             str 
-+
 = %22
-%5Cn%22
+%22;%0A                    endOfLine = true
 ;%0A              
@@ -2797,32 +2797,159 @@
 );%0A            %7D
+%0A%0A            if (endOfLine)%0A            %7B%0A                lines%5BlineNumber%5D = str;%0A                lineNumber++;%0A            %7D
 %0A        %7D%0A%0A    
@@ -2951,35 +2951,37 @@
 %0A        return 
-str
+lines
 ;%0A    %7D%0A%0A    pri

Update Scaffold.java