Exemplo n.º 1
0
        public WeatherDto Clima(int day)
        {
            var galaxy  = CreateGalaxy();
            var weather = new WeatherDto(day);

            galaxy.SetPositionToPlanets(day);

            if (WeatherCondition.IsDrought(galaxy))
            {
                weather.Weather = "Sequia";
            }
            else if (WeatherCondition.IsRaining(galaxy))
            {
                weather.Weather = "Lluvia";
            }
            else if (WeatherCondition.IsOptimal(galaxy))
            {
                weather.Weather = "Optimo";
            }
            else
            {
                weather.Weather = "Desconocido";
            }

            return(weather);
        }
Exemplo n.º 2
0
        public WeatherResumeDto GetWeatherResume()
        {
            var weatherResume = CreateWeatherResume();

            var galaxy = CreateGalaxy();

            // 1 year = 360 days

            for (int day = 1; day <= 3600; day++)
            {
                galaxy.SetPositionToPlanets(day);

                if (WeatherCondition.IsDrought(galaxy))
                {
                    weatherResume.DroughtDays++;
                }
                else if (WeatherCondition.IsRaining(galaxy))
                {
                    var galaxyPerimeter = galaxy.GetPerimeter();

                    weatherResume.RainDays++;

                    if (weatherResume.MaxPerimeter < galaxyPerimeter)
                    {
                        weatherResume.RainPeakDay  = day;
                        weatherResume.MaxPerimeter = galaxyPerimeter;
                    }
                }
                else if (WeatherCondition.IsOptimal(galaxy))
                {
                    weatherResume.OptimalDays++;
                }
                else
                {
                    weatherResume.UnknownDays++;
                }
            }

            return(weatherResume);
        }