Beispiel #1
0
        private void GenerateAllShipsByType(ShipType shipType, int numberOfShipsByType, List <Ship> existingShips, int panelSize)
        {
            var shipGenerator = new ShipGenerator();

            for (var i = 0; i < numberOfShipsByType; i++)
            {
                var currentShip = GetNextValidShip(existingShips, shipGenerator, shipType, panelSize);
                existingShips.Add(currentShip);
            }
        }
Beispiel #2
0
        private Ship GetNextValidShip(List <Ship> ships, ShipGenerator shipGenerator, ShipType shipType, int panelSize)
        {
            var  shipValidator = new ShipValidator();
            Ship currentShip;

            do
            {
                currentShip = shipGenerator.GenerateShip(shipType, panelSize);
            } while (!shipValidator.IsShipValidForList(currentShip, ships));

            return(currentShip);
        }