public class Robot
{
   /**
      Constructs a robot at (0, 0). The robot faces north.
   */
   public Robot()
   {
      x = 0;
      y = 0;
      dx = 0;
      dy = -1;
   }

   /**
      Moves this robot in the direction into which it faces.
   */
   public void moveForward() 
   {
      x = x + dx;
      y = y + dy;
   }

   /**
      Moves this robot away from the direction into which it faces.
   */
   public void moveBackward() 
   {
      x = x - dx;
      y = y - dy;
   }

   /**
      Turns this robot left.
   */
   public void turnLeft()
   {
      int newDx = dy;
      dy = -dx;
      dx = newDx;
   }
   
   /**
      Turns this robot right.
   */
   public void turnRight()
   {
      int newDx = -dy;
      dy = dx;
      dx = newDx;
   }

   /**
      Returns a string describing the robot's position
   */
   public String getPosition()
   {
      return "(" + x + ", " + y + ")";
   }

    private int x;
    private int y;
    private int dx;
    private int dy;
}
