示例#1
0
        public bool AddShip(IBattlefield battlefield, IShip ship, ShipPlacement placement)
        {
            if (!ship.CanPlace(battlefield, placement))
            {
                return(false);
            }

            ship.Place(battlefield, placement);
            return(true);
        }
示例#2
0
        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);
        }