} //Auto property //Default constructor public Galaxy() { GalaxyHubbleType = HubbleType.E0; Redshift = 0; TotalMass = 1e7; MassFraction = 0; Satellites = new System.Collections.Generic.List <Galaxy> { }; }
//Parameterised constructor public Galaxy(HubbleType HubbleTypeIn, double RedShiftIn, double TotalMassIn, double MassFractionIn) { if (RedShiftIn < 0 || RedShiftIn > 10) { throw new System.Exception("Redshift not in range"); } if (TotalMassIn < 1e7 || TotalMassIn > 1e12) { throw new System.Exception("Total mass not in range"); } if (MassFractionIn < 0 || MassFractionIn > 0.05) { throw new System.Exception("Mass fraction not in range"); } GalaxyHubbleType = HubbleTypeIn; Redshift = RedShiftIn; TotalMass = TotalMassIn * SolarMass; MassFraction = MassFractionIn; Satellites = new System.Collections.Generic.List <Galaxy> { }; }
public void AddSatellite(HubbleType HubbleTypeIn, double RedShiftIn, double TotalMassIn, double MassFractionIn) { Satellites.Add(new Galaxy(HubbleTypeIn, RedShiftIn, TotalMassIn, MassFractionIn)); }