public void TestProcessRoverMovementInstructionsRoverMovesTwoMs() { Platue currentPlatue=new Platue(new Point(10,10)); IRover currentRover=new Rover(new Point(0,0), CardinalCompassPoints.N ); IEnumerable<char> instructions = new List<char>() {'M', 'M'}; IRoverBusinessLogic businessLogic = new RoverBusinessLogic(new InputParser(currentPlatue, currentRover, instructions)); string actualNewPosition=businessLogic.ProcessRoverMovementInstructions(); string expectedRoverPosition = "0 2 N"; Assert.IsTrue(expectedRoverPosition==actualNewPosition); }
static void Main(string[] args) { Console.WriteLine("Please enter Platue size input:"); // Prompt string platueSize = Console.ReadLine(); IInputParser inputParser=new InputParser(); bool successful = inputParser.ParsePlatueInput(platueSize); while ( !successful) { Console.WriteLine("The platue size is invalid. Please enter Platue size input:"); // Prompt platueSize = Console.ReadLine(); successful = inputParser.ParsePlatueInput(platueSize); } while (true) { Console.WriteLine("Enter Position of Rover input:"); // Prompt string positionOfRover = Console.ReadLine(); successful = inputParser.ParseInputRoverPosition(positionOfRover); while (!successful) { Console.WriteLine("The position of rover is invalid. Please enter again:"); // Prompt positionOfRover = Console.ReadLine(); successful = inputParser.ParseInputRoverPosition(positionOfRover); } Console.WriteLine("Enter movement instructions for the rover:"); // Prompt string roverMovementInstructions = Console.ReadLine(); successful = inputParser.ParseMovementInstructions(roverMovementInstructions); while (!successful) { Console.WriteLine("Enter movement instructions for the rover:"); // Prompt roverMovementInstructions = Console.ReadLine(); successful = inputParser.ParseMovementInstructions(roverMovementInstructions); } IRoverBusinessLogic myRoverBusinessLogic = new RoverBusinessLogic(inputParser); string roversNewPosition = myRoverBusinessLogic.ProcessRoverMovementInstructions(); Console.WriteLine("The new position of the rover is "+roversNewPosition); } }