static void Main(string[] args) { var commandList = InputUtil.BuildCmdList(); String[] plateaUpper = commandList[0].ToString().Split(" "); Plateau plateau = new Plateau(Int32.Parse(plateaUpper[0]), Int32.Parse(plateaUpper[1])); List <String> roverInput = commandList.GetRange(1, commandList.Count - 1); for (int commandIndex = 0; commandIndex < roverInput.Count; commandIndex += 2) { Rover rover = InputUtil.parsePositionInput(roverInput[commandIndex], plateau); List <Command> commands = InputUtil.parseCommandInput(roverInput[commandIndex + 1]); rover.executeCommandList(commands); Console.WriteLine(rover.broadcastLocation()); } }
public Rover(Plateau plateau, int coordinateX, int coordinateY, Direction direction) { if (plateau == null) { throw new Exception("The Plateau you create the Rover in cannot be null!"); } if (direction == null) { throw new Exception("The Direction the Rover is facing in cannot be null!"); } this.plateau = plateau; this.coordinateX = coordinateX; this.coordinateY = coordinateY; this.direction = direction; validateLocation(); }