public void PlaceAllShips(Board board) { foreach (var shipPlacement in GetAllShips()) { board.Occupy(shipPlacement.Ship, shipPlacement.Orientation, shipPlacement.GridReference); } }
public void PlaceAllShips(Board board) { var ships = new List<Ship>(); ships.Add(new Ship("Patrol boat")); ships.Add(new Ship("Destroyer")); ships.Add(new Ship("Submarine")); ships.Add(new Ship("Battleship")); ships.Add(new Ship("Carrier")); foreach (var ship in ships) { bool shipIsNotPlaced = true; while (shipIsNotPlaced) { try { board.Occupy(ship, Orientationgenerator.Create(), GridReferenceGenerator.Create()); shipIsNotPlaced = false; } catch (Exception) { shipIsNotPlaced = true; } } } }