Пример #1
0
        public Ship(
            ShipClass shipClass,
            ShipOrientation orientation,
            ShipCoordinate headCoordinate,
            List <ShipCoordinate> cells
            )
        {
            ShipClass      = shipClass ?? throw new ArgumentNullException(nameof(shipClass));
            Orientation    = orientation;
            HeadCoordinate = headCoordinate ?? throw new ArgumentNullException(nameof(headCoordinate));

            if (!ShipAllocationLogic.ValidateShipBarier(headCoordinate, shipClass.Length, orientation))
            {
                throw new ArgumentException("Ship out of the board.");
            }

            Cells = cells.Select(item => new ShipCell(item)).ToList();
        }
 private static IEnumerable <Tuple <ShipCoordinate, ShipOrientation> > GetRandomShipCoordinateAndOrientationInBorder(int shipLength)
 {
     return(GetRandomShipCoordinateAndOrientation().Where(item => ShipAllocationLogic.ValidateShipBarier(item.Item1, shipLength, item.Item2)));
 }