示例#1
0
        private static Moon createMoon()
        {
            Moon moonX = new Moon();

            moonX.name = "The Moon";
            //moonX.surface = ‎37930000;
            moonX.radius = 1737;
            moonX.mass   = 5.972 * 10e-22;

            return(moonX);
        }
示例#2
0
        private static SolarSystem convertProviderToSolarSys(List <PlanetProvider> planetsProvider, List <SatelitesProvider> satelitesProvider)
        {
            SolarSystem solarSystem = new SolarSystem();

            solarSystem.planets = new List <Planet>();
            Dictionary <int, Planet> planetDic = new Dictionary <int, Planet>();

            foreach (var planetProvider in planetsProvider)
            {
                Planet PlanetX = new Planet();
                PlanetX.name              = planetProvider.name;
                PlanetX.periodRotation    = planetProvider.rotationPeriod;
                PlanetX.periodTranslation = planetProvider.orbitalPeriod;
                PlanetX.mass              = planetProvider.mass;
                PlanetX.radius            = planetProvider.diameter / 2;
                PlanetX.distanceFromStar  = planetProvider.distanceFromSun;
                PlanetX.surface           = 4 * Math.PI * Math.Pow(planetProvider.diameter / 2, 2);
                PlanetX.solarSystem       = "The Solar System";
                PlanetX.moons             = new List <Moon>();

                planetDic.Add(planetProvider.id, PlanetX);
            }



            foreach (var satelite in satelitesProvider)
            {
                if (planetDic.ContainsKey(satelite.planetId))
                {
                    Moon sateliteX = new Moon();
                    sateliteX.name    = satelite.name;
                    sateliteX.radius  = satelite.radius;
                    sateliteX.surface = 4 * Math.PI * Math.Pow(satelite.radius, 2);

                    planetDic[satelite.planetId].moons.Add(sateliteX);
                }
            }

            foreach (var planet in planetDic)
            {
                solarSystem.planets.Add(planet.Value);
            }

            return(solarSystem);
        }