コード例 #1
0
        public string ProcessSimulation(string input)
        {
            var command = _inputHelper.GetCommand(input);

            switch (command)
            {
            case Commands.Place:
                var position = _inputHelper.GetPosition(input);
                if (_tableTop.IsValid(position))
                {
                    var direction = _inputHelper.GetDirection(input);
                    _toyRobot.Place(direction, position);
                }
                break;

            case Commands.Move:
                var newPosition = _toyRobot.GetNewPosition();
                if (_tableTop.IsValid(newPosition))
                {
                    _toyRobot.SetNewPosition(newPosition);
                }
                break;

            case Commands.Left:
                _toyRobot.Rotate(Commands.Left);
                break;

            case Commands.Right:
                _toyRobot.Rotate(Commands.Right);
                break;

            case Commands.Report:
                return(_toyRobot.GetCurrentReport());
            }
            return(string.Empty);
        }