public SurfaceComposition GetCombinedComposition() { var sc = new SurfaceComposition(); foreach (var city in Cities) { sc = sc + city.surfaceComposition; } return sc; }
public static SurfaceComposition operator +(SurfaceComposition lhs, SurfaceComposition rhs) { var v = new SurfaceComposition(); v.composition.AddRange(lhs.composition); var extra = new List<Chemical>(); foreach (var c in v.composition) { foreach (var rc in rhs.composition) { if (c.name == rc.name) { c.percentage = (c.percentage + rc.percentage)/2; } else { extra.Add(rc); } } } v.composition.AddRange(extra); return v; }
public City() { surfaceComposition = new SurfaceComposition(); }