예제 #1
0
        // ----------------------------------------------------------------------------------------
        /// <!-- ShowDetails -->
        /// <summary>
        ///      Lists the details for the top num characteristics in the endeme
        /// </summary>
        /// <param name="num"></param>
        /// <param name="endeme"></param>
        /// <remarks>production ready</remarks>
        public string ShowDetails(int num, Endeme endeme)
        {
            string str   = "";
            string delim = "";

            for (int i = 0; i < num; ++i)
            {
                EndemeCharacteristic c = _char[endeme[i]];
                str  += delim + c.Letter + ". " + c.Label.PadRight(22) + " " + c.Descr;
                delim = "\r\n";
            }
            return(str);
        }
예제 #2
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Add -->
        /// <summary>
        ///      Adds a characteristic to the endeme set
        /// </summary>
        /// <param name="cha"></param>
        /// <param name="label"></param>
        /// <param name="descr"></param>
        /// <remarks>production ready</remarks>
        public void Add(EndemeCharacteristic characteristic)
        {
            char cha = characteristic.Letter;

            if (cha > 'Z')
            {
                cha = (char)((int)cha - 32);  // convert to upper case
                characteristic.LetterToUpper();
            }
            if (!_char.ContainsKey(cha))
            {
                _char.Add(characteristic.Letter, characteristic);
            }
            else
            {
                Pause();
            }
        }
예제 #3
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Equals -->
        /// <summary>
        ///      Two characteristics are equal if their letter and label are the same
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        /// <remarks>production ready</remarks>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (System.Object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(EndemeCharacteristic))
            {
                return(false);
            }
            EndemeCharacteristic target = (EndemeCharacteristic)obj;
            bool same = this.Letter == target.Letter && this.Label == target.Label;

            return(same);
        }
예제 #4
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Equals -->
        /// <summary>
        ///      Returns similarity of two sets - same name, same version, same letters, same labels,
        ///      does not check other details
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        /// <remarks>production ready</remarks>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(obj, this))
            {
                return(true);
            }
            if (obj.GetType() != typeof(EndemeSet))
            {
                return(false);
            }
            EndemeSet target = (EndemeSet)obj;


            bool same
                = (this.Label == target.Label) &&
                  (this.Version == target.Version) &&
                  (this.Count == target.Count)
                ;

            if (same)
            {
                foreach (char c in _char.Keys)
                {
                    EndemeCharacteristic cha = this[c];
                    if (cha != target[c])
                    {
                        same = false;
                        break;
                    }
                }
                return(same);
            }
            else
            {
                return(false);
            }
        }