Exemple #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;
            }
        }
Exemple #2
0
 public override void Execute(IRover rover, Instruction instruction)
 {
     switch (instruction.GetInstruction())
     {
         case Instruction.TurnLeft:
             rover.SetFacing(North);
             break;
         case Instruction.TurnRight:
             rover.SetFacing(South);
             break;
         case Instruction.MoveForward:
             rover.MoveEast();
             break;
         default:
             throw new ArgumentException("Incorrect facing code.");
     }
 }