public bool AddShip(IBattlefield battlefield, IShip ship, ShipPlacement placement) { if (!ship.CanPlace(battlefield, placement)) { return(false); } ship.Place(battlefield, placement); return(true); }
public bool AddShip(IBattlefield battlefield, IShip ship) { for (var i = 0; i < _maxAttempts; i++) { var placement = NextShipPlacement(battlefield); if (ship.CanPlace(battlefield, placement)) { ship.Place(battlefield, placement); return(true); } } return(false); }