Пример #1
0
        public void Add(Ship ship)
        {
            if (ship.X < POSITION_MIN || ship.EndX > POSITION_MAX ||
                ship.Y < POSITION_MIN || ship.EndY > POSITION_MAX)
            {
                throw new ArgumentOutOfRangeException();
            }

            for (int i = 0; i < ships.Count; i++)
            {
                if (ship.OverlapsWith(ships[i]))
                {
                    throw new ShipOverlapException();
                }
            }

            ships.Add(ship);
        }