import java.util.*;
import java.io.*;

public class Util
{
    public static char getNextFacing (char current, Command c)
    {
        // no real error checking!

        int currentAngle = 0;

        switch (current)
        {
            case Direction.SOUTH:
            {
                currentAngle = 180;
            }
            break;
            case Direction.EAST:
            {
                currentAngle = 90;
            }
            break;
            case Direction.WEST:
            {
                currentAngle = 270;
            }
            default:
            {
                // no op
            }
        }

        // assume no rotations > 270 degrees

        if (c.action() == Action.LEFT)
            currentAngle -= c.quantity();
        else
            currentAngle += c.quantity();

        switch (currentAngle)
        {
            case 0:
                return Direction.NORTH;
            case 90:
                return Direction.EAST;
            case 180:
                return Direction.SOUTH;
            default:
                return Direction.WEST;
        }        
    }

    public static final Vector<Command> loadCommands (String inputFile, boolean debug)
    {
        /*
         * Open the data file and read it in.
         */

        BufferedReader reader = null;
        Vector<Command> values = new Vector<Command>();

        try
        {
            reader = new BufferedReader(new FileReader(inputFile));
            String line = null;

            while ((line = reader.readLine()) != null)
            {
                char action = line.charAt(0);
                int amount = Integer.parseInt(line.substring(1));

                switch (action)
                {
                    case Action.EAST:
                    case Action.WEST:
                    case Action.NORTH:
                    case Action.SOUTH:
                    case Action.LEFT:
                    case Action.RIGHT:
                    case Action.FORWARD:
                    {
                        values.add(new Command(action, amount));
                    }
                    break;
                    default:
                    {
                        System.out.println("Unknown action: "+action);
                    }
                    break;
                }
            }
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }

        return values;
    }

    private Util ()
    {
    }
}
@@ -113,32 +113,90 @@
 ommand c)%0A    %7B%0A
+        System.out.println(%22Facing %22+current+%22 and %22+c);%0A%0A
         // no re
@@ -304,27 +304,27 @@
 e Direction.
-SOU
+NOR
 TH:%0A        
@@ -360,18 +360,17 @@
 Angle = 
-18
+9
 0;%0A     
@@ -420,28 +420,29 @@
 e Direction.
-EAST
+SOUTH
 :%0A          
@@ -468,33 +468,34 @@
  currentAngle = 
-9
+27
 0;%0A            %7D
@@ -584,34 +584,34 @@
  currentAngle = 
-27
+18
 0;%0A            %7D
@@ -603,32 +603,51 @@
 ;%0A            %7D%0A
+            break;%0A
             defa
@@ -689,16 +689,42 @@
 // no op
+ for East, i.e., angle = 0
 %0A       
@@ -733,32 +733,95 @@
    %7D%0A        %7D%0A%0A
+        System.out.println(%22Current angle is %22+currentAngle);%0A%0A
         // assum
@@ -918,9 +918,9 @@
 gle 
--
++
 = c.
@@ -961,33 +961,33 @@
    currentAngle 
-+
+-
 = c.quantity();%0A
@@ -983,24 +983,164 @@
 uantity();%0A%0A
+        if (currentAngle %3C 0)%0A            currentAngle += 360;%0A            %0A        System.out.println(%22Current angle now %22+currentAngle);%0A%0A
         swit
@@ -1184,16 +1184,17 @@
    case 
+9
 0:%0A     
@@ -1237,33 +1237,34 @@
            case 
-9
+18
 0:%0A             
@@ -1283,18 +1283,18 @@
 rection.
+W
 E
-A
 ST;%0A    
@@ -1298,34 +1298,34 @@
            case 
-18
+27
 0:%0A             
@@ -1397,34 +1397,34 @@
 eturn Direction.
-W
 E
+A
 ST;%0A        %7D   

Update Util.java