コード例 #1
0
ファイル: RoverCommand.cs プロジェクト: tncykurt/RoverProject
        public IRoverLocation TurnRight(IRoverLocation _roverLocation)
        {
            IRoverLocation newLocation = _roverLocation;

            switch (_roverLocation.RoverDirection)
            {
            case Direction.W:
                newLocation.RoverDirection = Direction.N;
                break;

            case Direction.N:
                newLocation.RoverDirection = Direction.E;
                break;

            case Direction.E:
                newLocation.RoverDirection = Direction.S;
                break;

            case Direction.S:
                newLocation.RoverDirection = Direction.W;
                break;

            default:
                break;
            }
            return(newLocation);
        }
コード例 #2
0
ファイル: RoverCommand.cs プロジェクト: tncykurt/RoverProject
        public IRoverLocation Go(IRoverLocation _roverLocation)
        {
            IRoverLocation newLocation = _roverLocation;

            switch (_roverLocation.RoverDirection)
            {
            case Direction.W:
                newLocation.xCoordinat = _roverLocation.xCoordinat - 1;
                break;

            case Direction.N:
                newLocation.yCoordinat = _roverLocation.yCoordinat + 1;
                break;

            case Direction.E:
                newLocation.xCoordinat = _roverLocation.xCoordinat + 1;
                break;

            case Direction.S:
                newLocation.yCoordinat = _roverLocation.yCoordinat - 1;
                break;

            default:
                break;
            }
            return(newLocation);
        }
コード例 #3
0
ファイル: RoverCommand.cs プロジェクト: tncykurt/RoverProject
        public IRoverLocation DoIt(CommandType commandType, IRoverLocation roverLocation)
        {
            switch (commandType)
            {
            case CommandType.L:
                return(TurnLeft(roverLocation));

            case CommandType.R:
                return(TurnRight(roverLocation));

            case CommandType.M:
                return(Go(roverLocation));

            default:
                throw new WrongCommandException(commandType.ToString());
            }
        }