Exemplo n.º 1
0
        public void Move(IRover rover, int places)
        {
            switch (rover.Direction)
            {
            case Direction.North:
                rover.Direction = Direction.East;
                rover.MoveEast(places);
                break;

            case Direction.East:
                rover.Direction = Direction.South;
                rover.MoveSouth(places);
                break;

            case Direction.South:
                rover.Direction = Direction.West;
                rover.MoveWest(places);
                break;

            case Direction.West:
                rover.Direction = Direction.North;
                rover.MoveNorth(places);
                break;
            }
        }
Exemplo n.º 2
0
 public override void Execute(IRover rover, Instruction instruction)
 {
     switch (instruction.GetInstruction())
     {
         case Instruction.TurnLeft:
             rover.SetFacing(South);
             break;
         case Instruction.TurnRight:
             rover.SetFacing(North);
             break;
         case Instruction.MoveForward:
             rover.MoveWest();
             break;
         default:
             throw new ArgumentException("Incorrect facing code.");
     }
 }