Beispiel #1
0
 private static void AddPlanetsTothePlanetSystemAndAddSatellitesToEachPlanet(PlanetSystem planetSystem, string planetTxtFile, string doruforoiTxtFile, string aktinaDoruforouTxtFile, string PeriodosPeristrofisDoruforouTxtFile)
 {
     if (File.Exists(planetTxtFile) && File.Exists(doruforoiTxtFile))
     {
         string[] planetLines          = File.ReadAllLines(planetTxtFile);
         string[] doruforoiLines       = File.ReadAllLines(doruforoiTxtFile);
         string[] aktinaDoruforouLines = File.ReadAllLines(aktinaDoruforouTxtFile);
         string[] periodosPeristrofisDoruforouLines = File.ReadAllLines(PeriodosPeristrofisDoruforouTxtFile);
         int      j = 0;
         for (int i = 0; i < 90; i++)
         {
             Planet RandomPlanet = new Planet
             {
                 PlanetName = planetLines[i],
                 MesiApostasiApoTonAsteraTou = Convert.ToDouble(planetLines[i + 1]),
                 PlanetMass          = Convert.ToDouble(planetLines[i + 2]),
                 PeriodosPeriforas   = Convert.ToDouble(planetLines[i + 3]),
                 PeriodosPeristrofis = Convert.ToDouble(planetLines[i + 4]),
                 Daxtulioi           = Convert.ToBoolean(planetLines[i + 5]),
                 GhinosPlanitis      = Convert.ToBoolean(planetLines[i + 6]),
                 AerinosPlanitis     = Convert.ToBoolean(planetLines[i + 7]),
                 DwarfPlanet         = Convert.ToBoolean(planetLines[i + 8]),
                 Atmosphere          = planetLines[i + 9],
                 ListOfSatellites    = new List <Satellite>()
             };
             i += 9;
             if (RandomPlanet.PlanetName != "Ermis" && RandomPlanet.PlanetName != "Afroditi")
             {
                 for (; ;)
                 {
                     if (doruforoiLines[j] == "")
                     {
                         j++;
                         break;
                     }
                     else
                     {
                         Satellite satellite = new Satellite();
                         satellite.SatelliteName       = doruforoiLines[j];
                         satellite.AktinaTouDoruforou  = Convert.ToDouble(aktinaDoruforouLines[j]);
                         satellite.PeriodosPeristrofis = Convert.ToDouble(periodosPeristrofisDoruforouLines[j]);
                         RandomPlanet.ListOfSatellites.Add(satellite);
                         j++;
                     }
                 }
             }
             PrintThePlanetAndAllItsDetails(RandomPlanet);
             planetSystem.listOfPlanets.Add(RandomPlanet);
         }
     }
 }