static public ArrayList NumberOfStarsOfType(ArrayList exoplanets, string type) { ArrayList stars = new ArrayList(); foreach (Exoplanet exoplanet in exoplanets) { if (exoplanet.IsType(type)) { if (exoplanet.Star.Name != null) { bool addStar = true; for (int index = 0; index < stars.Count && addStar; ++index) { StarTypes star = stars [index] as StarTypes; if (exoplanet.Star.Name == star.Name) { ++star.Count; addStar = false; } } if (addStar) { StarTypes star = new StarTypes(); star.Name = exoplanet.Star.Name; star.Count = 0; star.IsSpectualType = false; stars.Add(star); } } } } foreach (Exoplanet exoplanet in exoplanets) { for (int index = 0; index < stars.Count; ++index) { StarTypes star = stars [index] as StarTypes; if (exoplanet.Star.Name == star.Name) { ++star.NumberOfPlanets; } } } return(stars); }
static public ArrayList NumberOfStarTypes(ArrayList exoplanets) { ArrayList types = new ArrayList(); foreach (Exoplanet exoplanet in exoplanets) { if (exoplanet.Star.Property.SPType != null) { bool addType = true; for (int index = 0; index < types.Count && addType; ++index) { StarTypes type = types [index] as StarTypes; if (exoplanet.Star.Property.SPType.Substring(0, 1) == type.Name) { ++type.Count; addType = false; } } if (addType) { StarTypes type = new StarTypes(); type.Name = exoplanet.Star.Property.SPType.Substring(0, 1); type.Count = 1; type.IsSpectualType = (type.Name == "O" || type.Name == "B" || type.Name == "A" || type.Name == "F" || type.Name == "G" || type.Name == "K" || type.Name == "M") ? true : false; types.Add(type); } } } return(types); }