public void PlaceShips(ISquare[,] grid, IShip[] ships) { // assuming that grid is a square var gridSize = grid.GetLength(0); foreach (var ship in ships) { bool wasShipSuccesfullyPlaced = false; while (!wasShipSuccesfullyPlaced) { var orientation = _random.GetOrientation(); var coordinates = _random.GetCoordinates(gridSize, ship.Size, orientation); wasShipSuccesfullyPlaced = TryPlaceShip( grid, ship, orientation, coordinates ); } } }