/// <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); }
public override bool AddChild(StellarObject child) { if (child.ObjectType == StellarType.Planet) { children.Add(child); return(true); } return(false); }
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); }
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); }
public override bool RemoveChild(StellarObject child) { return(false); }
public abstract bool RemoveChild(StellarObject child);
public abstract bool AddChild(StellarObject child);
public override bool RemoveChild(StellarObject child) { return(children.Remove(child)); }