public void MoveWestThenReturnTest() { var robotCleaner = new RobotCleaner.RobotCleaner(0, 0); var robotInstructionWest = new RobotInstruction("W 55"); var robotInstructionEast = new RobotInstruction("E 55"); robotCleaner.ExecuteInstructions(new List <RobotInstruction>() { robotInstructionWest, robotInstructionEast }); Assert.AreEqual(56, robotCleaner.GetCleanedLocationsCount()); }
public void MoveNorthThenReturnTest() { var robotCleaner = new RobotCleaner.RobotCleaner(0, 0); var robotInstructionNorth = new RobotInstruction("N 100"); var robotInstructionSouth = new RobotInstruction("S 100"); robotCleaner.ExecuteInstructions(new List <RobotInstruction>() { robotInstructionNorth, robotInstructionSouth }); Assert.AreEqual(101, robotCleaner.GetCleanedLocationsCount()); }
public void MoveNorthTest() { var robotCleaner = new RobotCleaner.RobotCleaner(0, 0); var robotInstruction = new RobotInstruction("S 100"); robotCleaner.ExecuteInstructions(new List <RobotInstruction>() { robotInstruction }); var robotPosition = robotCleaner.GetCurrentLocation(); Assert.AreEqual(0, robotPosition.X); Assert.AreEqual(-100, robotPosition.Y); }
static void Main(string[] args) { var numberOfComands = Int32.Parse(Console.ReadLine()); var startLocation = CommandParser.ParseRobotLocation(Console.ReadLine()); var robotCommands = new List<RobotCommand>(); for (int i = 0; i < numberOfComands; i++) { var command = CommandParser.ParseRobotCommand(Console.ReadLine()); robotCommands.Add(command); } var robot = new RobotCleaner(startLocation); robot.ExecuteCommands(robotCommands); Console.WriteLine("Cleaned: {0}", robot.GetCleanedLocations()); }
static void Main(string[] args) { var comandsCount = Console.ReadLine(); var currentPosition = Console.ReadLine(); var robotInstructions = new List <RobotInstruction>(); for (var i = 0; i < int.Parse(comandsCount); i++) { robotInstructions.Add(new RobotInstruction(Console.ReadLine())); } var robotCleaner = new RobotCleaner(int.Parse(currentPosition.Split(' ')[0]), int.Parse(currentPosition.Split(' ')[1])); robotCleaner.ExecuteInstructions(robotInstructions); Console.WriteLine(robotCleaner.GetCleanedLocationsCount()); }