Moved java source into its own folder
authorMichael Welch <michaelgwelch@gmail.com>
Sun, 26 Feb 2012 01:01:32 +0000 (19:01 -0600)
committerMichael Welch <michaelgwelch@gmail.com>
Sun, 26 Feb 2012 01:01:32 +0000 (19:01 -0600)
java/.classpath [moved from .classpath with 100% similarity]
java/.project [moved from .project with 100% similarity]
java/src/welch/brainmess/ExecutionContext.java [moved from src/welch/brainmess/ExecutionContext.java with 100% similarity]
java/src/welch/brainmess/Instruction.java [moved from src/welch/brainmess/Instruction.java with 100% similarity]
java/src/welch/brainmess/ListTraveler.java [moved from src/welch/brainmess/ListTraveler.java with 100% similarity]
java/src/welch/brainmess/Program.java [moved from src/welch/brainmess/Program.java with 100% similarity]
java/src/welch/brainmess/Tape.java [moved from src/welch/brainmess/Tape.java with 79% similarity]
java/test/welch/brainmess/TestTape.java [moved from test/welch/brainmess/TestTape.java with 89% similarity]

similarity index 100%
rename from .classpath
rename to java/.classpath
similarity index 100%
rename from .project
rename to java/.project
similarity index 79%
rename from src/welch/brainmess/Tape.java
rename to java/src/welch/brainmess/Tape.java
index c6e337e..41d4327 100644 (file)
@@ -95,7 +95,29 @@ public class Tape
         */
        public String toString()
        {
-               return list.toString();
+               StringBuilder builder = new StringBuilder();
+               int current = currentIndex();
+               
+               builder.append("[");
+               int i = 0;
+               boolean first = true;
+               for (int val : list)
+               {
+                       if (!first)
+                       {
+                               builder.append(", ");
+                       }
+                       else 
+                       {
+                               first = false;
+                       }
+                       if (i == current) builder.append("*");
+                       builder.append(val);
+                       if (i == current) builder.append("*");
+                       i++;
+               }
+               builder.append("]");
+               return builder.toString();
        }
        
        
similarity index 89%
rename from test/welch/brainmess/TestTape.java
rename to java/test/welch/brainmess/TestTape.java
index b7f981b..44a537d 100644 (file)
@@ -9,7 +9,7 @@ public class TestTape
        public void testConstructor()
        {
                // Should have one element set to 0.
-               assertEquals("[0]", new Tape().toString());
+               assertEquals("[*0*]", new Tape().toString());
        }
        
        @Test
@@ -17,7 +17,7 @@ public class TestTape
        {
                Tape tape = new Tape();
                tape.increment();
-               assertEquals("[1]", tape.toString());
+               assertEquals("[*1*]", tape.toString());
        }
        
        @Test
@@ -27,7 +27,7 @@ public class TestTape
                // increment first cell, so we can verify new cell comes before
                tape.increment();
                tape.moveBackward();
-               assertEquals("[0, 1]", tape.toString());
+               assertEquals("[*0*, 1]", tape.toString());
        }
        
        @Test
@@ -37,7 +37,7 @@ public class TestTape
                // increment first cell, so we can verify new cell comes after
                tape.increment();
                tape.moveForward();
-               assertEquals("[1, 0]", tape.toString());
+               assertEquals("[1, *0*]", tape.toString());
        }
        
        @Test
@@ -45,7 +45,7 @@ public class TestTape
        {
                Tape tape = new Tape();
                tape.decrement();
-               assertEquals("[-1]", tape.toString());
+               assertEquals("[*-1*]", tape.toString());
        }
        
        @Test