コード例 #1
0
        }     // AddWife

        /// <summary>
        ///     Divorces a wife from this man
        /// </summary>
        /// <param name="wife">The wife to be divorced</param>
        // Pre: (wife != null) and (this.hasMarried(wife))
        public void RemoveWife(Woman wife)
        {
            wifes.Remove(wife);
            if (wife.HasMarried(this))
            {
                wife.RemoveHusband(this);
            } // if
        }     // RemoveWife
コード例 #2
0
        } // Man

        /// <summary>
        ///     Adds a new wife to the man's harem
        /// </summary>
        /// <param name="wife">The new wife for this lucky man</param>
        // Pre: wife != null
        public void AddWife(Woman wife)
        {
            wifes.Add(wife);
            if (!wife.HasMarried(this))
            {
                wife.AddHusband(this);
            } // if
        }     // AddWife
コード例 #3
0
        }     // RemoveWife

        /// <summary>
        ///     Checks whether this man has married the woman passed as a parameter
        /// </summary>
        /// <param name="wife">A woman</param>
        /// <returns>Turn if the man has married the woman passed as a parameter,
        ///          otherwise it returns false</returns>
        public bool HasMarried(Woman wife)
        {
            return(wifes.Contains(wife));
        } // HasMarried