public void RemoveUnit(Unit unit) { try { _units.Remove(unit); } catch (IndexOutOfRangeException ex) { throw new InvalidOperationException("Could not find Unit " + unit.ToString(), ex); } }
public void AddUnit(Unit unit) { if (!_units.Contains(unit)) { _units.Add(unit); } else { throw new InvalidOperationException("Unit " + unit.ToString() + " already exists!"); } }