Пример #1
0
        public string Move(string movements)
        {
            ValidateRoverSetting();
            string[] movementArray = InputParser.RoverMovementsParser(movements);

            foreach (string movement in movementArray)
            {
                if (movement.Equals(MovementAction.DirectionTypes.L.ToString()))
                {
                    MovementAction.SpinLeft();
                }
                else if (movement.Equals(MovementAction.DirectionTypes.R.ToString()))
                {
                    MovementAction.SpinRight();
                }
                else if (movement.Equals(MovementAction.DirectionTypes.M.ToString()))
                {
                    MovementAction.MoveForward();
                }
                else
                {
                    ;
                }
            }

            if (MovementAction.X > PlateauDimensionX || MovementAction.Y > PlateauDimensionY)
            {
                return(InputParser.ShowError(2));
            }

            return(ShowResult());
        }
Пример #2
0
        private void ValidateRoverSetting()
        {
            if (MovementAction.X == null || MovementAction.Y == null)
            {
                InputParser.ShowError(1);
            }

            else if (PlateauDimensionX == null || PlateauDimensionY == null)
            {
                InputParser.ShowError(1);
            }

            else if (MovementAction.X > PlateauDimensionX || MovementAction.Y > PlateauDimensionY)
            {
                InputParser.ShowError(2);
            }
        }