Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OECLib.Data.StellarObject"/>.
        /// </summary>
        /// <param name="other">The <see cref="System.Object"/> to compare with the current <see cref="OECLib.Data.StellarObject"/>.</param>
        /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
        /// <see cref="OECLib.Data.StellarObject"/>; otherwise, <c>false</c>.</returns>
        public override bool Equals(object other)
        {
            if (other == null | GetType() != other.GetType())
            {
                return(false);
            }

            StellarObject obj = (StellarObject)other;

            //we have no better method of comparing, so just do the base version
            if (names == null && obj.names == null)
            {
                return(base.Equals(other));
            }

            //otherwise compare names
            foreach (Measurement thisMeasure in names)
            {
                foreach (Measurement otherMeasure in obj.names)
                {
                    if (otherMeasure.MeasurementValue == thisMeasure.MeasurementValue)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 public override bool AddChild(StellarObject child)
 {
     if (child.ObjectType == StellarType.Planet)
     {
         children.Add(child);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        public override bool AddChild(StellarObject child)
        {
            StellarType childType = child.ObjectType;

            if ((numOfChildren == 0 || childType == StellarType.Planet) && childType != StellarType.System)
            {
                children.Add(child);
                if (childType != StellarType.Planet)
                {
                    numOfChildren++;
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public override bool AddChild(StellarObject child)
        {
            bool        canAdd        = (numberOfBinaries == 1 && numberOfStars == 0) || (numberOfBinaries == 0 && numberOfStars == 1) || (numberOfStars == 0 && numberOfStars == 0);
            bool        successfulAdd = false;
            StellarType childType     = child.ObjectType;

            if (canAdd || childType == StellarType.Planet)
            {
                children.Add(child);

                if (childType == StellarType.Binary)
                {
                    numberOfBinaries++;
                }
                else if (childType == StellarType.Star)
                {
                    numberOfStars++;
                }

                successfulAdd = true;
            }
            return(successfulAdd);
        }
Ejemplo n.º 5
0
 public override bool RemoveChild(StellarObject child)
 {
     return(false);
 }
Ejemplo n.º 6
0
 public abstract bool RemoveChild(StellarObject child);
Ejemplo n.º 7
0
 public abstract bool AddChild(StellarObject child);
Ejemplo n.º 8
0
 public override bool RemoveChild(StellarObject child)
 {
     return(children.Remove(child));
 }