import java.util.*;

public class Computer
{
    public Computer (boolean debug)
    {
        _accumulator = 0;
        _debug = debug;
    }

    public int executeUntilInfiniteLoop (Vector<OpCode> instructions)
    {
        int index = 0;
        OpCode op = instructions.elementAt(index);

        _accumulator = 0;

        if (_debug)
            System.out.println();
            
        while (!op.visited())
        {
            switch (op.type())
            {
                case OpCode.ACCUMULATOR:
                {
                    int value = ((Accumulator) op).getValue();

                    if (_debug)
                        System.out.println("acc: adding "+value+" to accumulator "+_accumulator);

                    _accumulator += value;
                }
                break;
                case OpCode.JUMP:
                {
                    int value = ((Jump) op).getStep();

                    if (_debug)
                        System.out.println("jmp: adding "+value+" to index "+index);

                    index += ((Jump) op).getStep();
                }
                break;
                case OpCode.NOOP:
                default:
                {
                    // no op!!

                    if (_debug)
                        System.out.println("nop");
                }
                break;
            }

            index++;

            op.visit();

            op = instructions.elementAt(index);
        }

        return _accumulator;
    }

    private int _accumulator;
    private boolean _debug;
}
@@ -84,34 +84,8 @@
   %7B%0A
-        _accumulator = 0;%0A
     
@@ -261,25 +261,24 @@
 index);%0A
-%0A
         
 _accumul
@@ -261,33 +261,36 @@
 index);%0A        
-_
+int 
 accumulator = 0;
@@ -291,16 +291,60 @@
 r = 0;%0A%0A
+        while (!op.visited())%0A        %7B%0A    
         
@@ -347,32 +347,50 @@
     if (_debug)%0A
+            %7B%0A    
             Syst
@@ -404,16 +404,39 @@
 println(
+%22%5CnInstruction: %22+index
 );%0A     
@@ -446,38 +446,65 @@
     
-%0A
     
-    while (!op.visited())
+System.out.println(%22Accumulator: %22+accumulator+%22%5Cn%22);
 %0A   
@@ -500,33 +500,38 @@
 +%22%5Cn%22);%0A        
-%7B
+    %7D%0A
 %0A            swi
@@ -798,17 +798,16 @@
 lator %22+
-_
 accumula
@@ -833,17 +833,16 @@
         
-_
 accumula
@@ -855,16 +855,45 @@
  value;%0A
+                    index++;%0A
         
@@ -1435,16 +1435,46 @@
 (%22nop%22);
+%0A%0A                    index++;
 %0A       
@@ -1526,30 +1526,8 @@
  %7D%0A%0A
-            index++;%0A%0A
     
@@ -1625,46 +1625,8 @@
 urn 
-_accumulator;%0A    %7D%0A%0A    private int _
 accu
@@ -1634,16 +1634,23 @@
 ulator;%0A
+    %7D%0A%0A
     priv

Update Computer.java