public virtual void AddSubordinate(UnitBase subordinate) { Contract.Requires<ArgumentNullException>(subordinate != null); Contract.Requires<ArgumentException>(!Subordinates.Contains(subordinate)); this._subordinates.Add(subordinate); subordinate.Superior = this; }
/// <summary> /// Removes a subordinate from the list of subordinates. /// </summary> /// <param name="subordinate">The subordinate to remove.</param> /// <exception cref="ArgumentNullException">When <paramref name="subordinate" /> is null.</exception> /// <exception cref="ArgumentException">When <paramref name="subordinate" /> is not on the list.</exception> public virtual void RemoveSubordinate(UnitBase subordinate) { Contract.Requires<ArgumentNullException>(subordinate != null); Contract.Requires<ArgumentException>(Subordinates.Contains(subordinate)); this._subordinates.Remove(subordinate); subordinate.Superior = null; }