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); }
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; } }
public Position(short x, short y, BattleShip battleShip) { X = x; Y = y; Status = StatusType.None; }