Ejemplo n.º 1
0
        /// <summary>
        /// Creates the report.
        /// </summary>
        /// <param name="daysForReport">The days for report.</param>
        /// <param name="bucketSize">Size of the bucket.</param>
        /// <returns>
        /// A full report outlining specific information based the supplied weather data
        /// </returns>
        public string CreateReport(WeatherDataCollection daysForReport, int bucketSize)
        {
            var report = new StringBuilder();

            this.bucketSize = bucketSize;
            var years = daysForReport.GroupByYear();

            foreach (var year in years)
            {
                var tempWeatherCollection = new WeatherDataCollection();
                foreach (var day in year)
                {
                    tempWeatherCollection.Add(day);
                }
            }

            report.Append(Environment.NewLine);

            this.createYearlyBreakdown(daysForReport, report);
            return(report.ToString());
        }
Ejemplo n.º 2
0
        private void createYearlyBreakdown(WeatherDataCollection daysForReport, StringBuilder report)
        {
            var years = daysForReport.GroupByYear();

            foreach (var year in years)
            {
                var tempWeatherCollection = new WeatherDataCollection();
                foreach (var day in year)
                {
                    tempWeatherCollection.Add(day);
                }

                this.createOverview(tempWeatherCollection, report);
                report.Append(Environment.NewLine);

                var upperBound = tempWeatherCollection.GetDaysWithHighestTempForAYear()[0].High;
                var lowerBound = tempWeatherCollection.GetDaysWithLowestHighTempByYear()[0].High;


                report.Append("Highest Temp Histogram" + Environment.NewLine);
                this.createHistogram(report, tempWeatherCollection, lowerBound, upperBound, this.bucketSize, HighLow.High);
                report.Append(Environment.NewLine);


                upperBound = tempWeatherCollection.GetDaysWithHighestLowTempByYear()[0].Low;
                lowerBound = tempWeatherCollection.GetDaysWithLowestTempByYear()[0].Low;


                report.Append("Lowest Temp Histogram" + Environment.NewLine);
                this.createHistogram(report, tempWeatherCollection, lowerBound, upperBound, this.bucketSize, HighLow.Low);
                report.Append(Environment.NewLine);


                this.createMonthlyBreakdown(tempWeatherCollection, report);
            }
        }