コード例 #1
0
ファイル: Rover.cs プロジェクト: irmakd/MarsRover
        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
ファイル: Rover.cs プロジェクト: irmakd/MarsRover
        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);
            }
        }