예제 #1
0
        public string Command(string command)
        {
            var             response    = "";
            InstructionArgs args        = null;
            var             instruction = GetInstruction(command, ref args);

            switch (instruction)
            {
            case Instruction.Place:
                var placeArgs = (PlaceArgs)args;
                response = _robotAction.Place(placeArgs.X, placeArgs.Y, placeArgs.Facing) ? "Command Success" : _robotAction.Error;
                break;

            case Instruction.Move:
                response = _robotAction.Move() ? "Command Success" : _robotAction.Error;
                break;

            case Instruction.Left:
                response = _robotAction.Left() ? "Command Success" : _robotAction.Error;
                break;

            case Instruction.Right:
                response = _robotAction.Right() ? "Command Success" : _robotAction.Error;
                break;

            case Instruction.Report:
                response = _robotAction.Report();
                break;

            case Instruction.Invalid:
                response = @"Invalid command. The correct command formats are as follows:
                    PLACE X, Y, DIRECTION
                    MOVE
                    RIGHT
                    LEFT
                    REPORT
                    -------------
                    Please review your input and try again.";
                break;

            default:
                response = @"Invalid command. The correct command formats are as follows:
                    PLACE X, Y, DIRECTION
                    MOVE
                    RIGHT
                    LEFT
                    REPORT
                    -------------
                    Please review your input and try again.";
                break;
            }
            return(response);
        }
예제 #2
0
 public void Robot_PlacedAndTurnedRight_ReportsCorrectPosition()
 {
     robotAction.Place(1, 1, Facing.North);
     robotAction.Right();
     Assert.AreEqual("1,1,EAST", robotAction.Report());
 }