public static int GetTotalValue(WeatherDays[] weather, string month)
 {
     var totalValue = 0;
     for (var i = 0; i < weather.Length; i++)
         if (weather[i].Month == month)
             totalValue += weather[i].MaxTemperature;
     return totalValue;
 }
 public static WeatherDays[] GetTheHottestDay(WeatherDays[] weather)
 {
     var maxOfMaxTemperature = GetMaxVaule(weather);
     var dayWithMaxTemperature = new WeatherDays[0];
     for (var i = 0; i < weather.Length; i++)
         if (weather[i].MaxTemperature == maxOfMaxTemperature)
             dayWithMaxTemperature = AddToArray(ref dayWithMaxTemperature, weather[i]);
     return dayWithMaxTemperature;
 }
 public static WeatherDays[] GetTheColdexDay(WeatherDays[] weather)
 {
     var minOfMaxTemperature = GetMinValue(weather);
     var dayWithMinOfMaxTemperature = new WeatherDays[0];
     for (var i = 0; i < weather.Length; i++)
         if (weather[i].MaxTemperature == minOfMaxTemperature)
             dayWithMinOfMaxTemperature = AddToArray(ref dayWithMinOfMaxTemperature, weather[i]);
     return dayWithMinOfMaxTemperature;
 }
 public static int GetMinValue(WeatherDays[] weather)
 {
     var minValue = weather[0].MaxTemperature;
     for (var i = 0; i < weather.Length; i++)
     {
         if (weather[i].MaxTemperature <= minValue)
             minValue = weather[i].MaxTemperature;
     }
     return minValue;
 }
 public static int GetMaxVaule(WeatherDays[] weather)
 {
     var maxValue = weather[0].MinTemperature;
     for (var i = 0; i < weather.Length; i++)
     {
         if (weather[i].MaxTemperature >= maxValue)
             maxValue = weather[i].MaxTemperature;
     }
     return maxValue;
 }
 public static int GetMaxDifference(WeatherDays[] weather)
 {
     var maxDifference = weather[0].MaxTemperature - weather[0].MinTemperature;
     for (var i = 0; i < weather.Length; i++)
     {
         var difference = weather[i].MaxTemperature - weather[i].MinTemperature;
         if (difference > maxDifference)
             maxDifference = difference;
     }
     return maxDifference;
 }
 public static float GetAveregeTemperature(WeatherDays[] weather, string month)
 {
     float averegeTemperature = 0;
     var index = 0;
     float totalOfMaxTemperature = GetTotalValue(weather, month);
     for (var i = 0; i < weather.Length; i++)
         if (weather[i].Month == month)
             index++;
     averegeTemperature = totalOfMaxTemperature / index;
     return averegeTemperature;
 }
Esempio n. 8
0
        /*
         * return the model object "WeatherDays"
         */
        public WeatherDays getThatList(WeatherView weather)
        {
            WeatherDays   weatherStruct = new WeatherDays();
            List <double> newList       = new List <double>();

            newList.Add(Convert.ToDouble(weather.january));
            newList.Add(Convert.ToDouble(weather.february));
            newList.Add(Convert.ToDouble(weather.march));
            newList.Add(Convert.ToDouble(weather.april));
            newList.Add(Convert.ToDouble(weather.may));
            newList.Add(Convert.ToDouble(weather.june));
            newList.Add(Convert.ToDouble(weather.july));
            newList.Add(Convert.ToDouble(weather.august));
            newList.Add(Convert.ToDouble(weather.september));
            newList.Add(Convert.ToDouble(weather.october));
            newList.Add(Convert.ToDouble(weather.november));
            newList.Add(Convert.ToDouble(weather.december));
            weatherStruct.setDays(newList);
            weatherStruct.setFeature(weather.feature);
            return(weatherStruct);
        }
Esempio n. 9
0
 public void AddDay(WeatherWeekDay day)
 {
     WeatherDays.Add(day);
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            WeatherDays june = new WeatherDays();

            june.UserChoice();
        }
 public static WeatherDays[] ResizeArray(WeatherDays[] oldArray, int difference)
 {
     var newArray = new WeatherDays[oldArray.Length + difference];
     for (var i = 0; i < oldArray.Length; i++)
         newArray[i] = oldArray[i];
     return newArray;
 }
 public static WeatherDays[] AddToArray(ref WeatherDays[] array, WeatherDays newValue)
 {
     array = ResizeArray(array, 1);
     array[array.Length - 1] = newValue;
     return array;
 }