public Coordinates GetStartingCoordinatesForShip(Ship ship, ShipOrientation orientation) { int endIndex = GetEndIndexForShipRandom(ship, orientation); int firstCoordinate = _randFirstCoordinateOfShip.Next(1, endIndex); int endIndexForSecondCoordinate = orientation == ShipOrientation.Vertical ? _board.Columns - 1 : _board.Rows - 1; int secondCoordinate = _randSecondCoordinateOfShip.Next(1, endIndexForSecondCoordinate); int x = orientation == ShipOrientation.Vertical ? firstCoordinate : secondCoordinate; int y = orientation == ShipOrientation.Horizontal ? firstCoordinate : secondCoordinate; var coordinate = new ShipCoordinates(x, y); return(coordinate); }
public Ship(int length) { Id = Guid.NewGuid(); CoordinatesFields = new ShipCoordinates[length]; }