Exemplo n.º 1
0
        private RoverPosition Move(RoverPosition start)
        {
            var backup = new RoverPosition()
            {
                Name = start.Name, Direction = start.Direction, X = start.X, Y = start.Y
            };

            switch (start.Direction)
            {
            case 'E':
                start.X++;
                break;

            case 'S':
                start.Y--;
                break;

            case 'W':
                start.X--;
                break;

            case 'N':
                start.Y++;
                break;

            default:
                break;
            }

            // Validate the movement
            return(_environmentSerive.ValidateMove(start)?start : backup);
        }