public void Add(IShip ship) { foreach (var shipOnBoard in _shipsOnBoard) { if (ship.OverlapsWith(shipOnBoard)) throw new ShipOverlapException($"Ship {ship.GetNotation()} overlaps with {shipOnBoard.GetNotation()}"); } var endX = ship.Direction == Direction.Vertical ? 0 : ship.Length - 1; var endY = ship.Direction == Direction.Vertical ? ship.Length - 1 : 0; if (ship.X > 10 || ship.Y > 10 || ship.Y < 0 || ship.Y > 10) throw new ArgumentOutOfRangeException(); if (ship.X + endX > 10 || ship.Y + endY > 10) throw new ArgumentOutOfRangeException(); _shipsOnBoard.Add(ship); }