Exemplo n.º 1
0
        private bool HasPositionFilled(BattleShip battleShip)
        {
            bool result = false;

            foreach (var position in battleShip.Positions)
            {
                if (_dimension[position.X, position.Y] != null)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void AddBattleShip(BattleShip battleShip)
        {
            if (!battleShip.CheckRangePosition())
            {
                throw new Exceptions.InvalidRangeException();
            }

            if (HasPositionFilled(battleShip))
            {
                throw new Exceptions.InvalidBattleShipPositionException();
            }

            _battleShips.Add(battleShip);
            foreach (var item in battleShip.Positions)
            {
                _dimension[item.X, item.Y] = item;
            }
        }
Exemplo n.º 3
0
 public Position(short x, short y, BattleShip battleShip)
 {
     X      = x;
     Y      = y;
     Status = StatusType.None;
 }