} // Equals /// <summary> /// Adds a new wife to the Mormon's harem /// </summary> /// <param name="wife">The wife to be added to the harem</param> // Pre: wife != null public void AddWife(Woman wife) { this.wifes.Add(wife); if ((wife.Husband == null) || (!wife.Husband.Equals(this))) { wife.Husband = this; } // if } //
} // removeWife /// <summary> /// Returns true if the woman passed as a parameter is in the Mormon's harem /// </summary> /// <param name="wife">The woman to be found</param> /// <returns>True if the woman is in the harem, otherwise false</returns> // Pre: wife != null public bool HasMarried(Woman wife) { return(wifes.Contains(wife)); } // isInHarem
} // /// <summary> /// The man gets divorced from the wife passed as a parameter /// </summary> /// <param name="wife">The woman to be divorced</param> // Pre: wife != null public void RemoveWife(Woman wife) { this.wifes.Remove(wife); wife.Husband = null; } // removeWife