private string formatDaysWithHighestTempForYear(WeatherDataCollection daysForReport) { var dates = new List <string>(); foreach (var current in daysForReport.GetDaysWithHighestTempForAYear()) { dates.Add(current.Date.ToShortDateString()); } var daysWithHighest = string.Join(",", dates); return(daysWithHighest); }
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); } }
private void createOverview(WeatherDataCollection daysForReport, StringBuilder report) { var dates = new List <string>(); foreach (var current in daysForReport.GetDaysWithHighestLowTempByYear()) { dates.Add(current.Date.ToShortDateString()); } var daysWithHighestLow = string.Join(", ", dates); report.Append( $"Highest temp occurred on {this.formatDaysWithHighestTempForYear(daysForReport)}: {daysForReport.GetDaysWithHighestTempForAYear()[0].High}" + Environment.NewLine); report.Append( $"Lowest temp occurred on {this.formatDaysWithLowestTempForYear(daysForReport)}: {daysForReport.GetDaysWithLowestTempByYear()[0].Low}" + Environment.NewLine); report.Append( $"Lowest high temp occurred on {this.formatDaysWithLowestHighTempForYear(daysForReport)}: {daysForReport.GetDaysWithLowestHighTempByYear()[0].High}" + Environment.NewLine); report.Append( $"Highest low temp occurred on {daysWithHighestLow}: {daysForReport.GetDaysWithHighestLowTempByYear()[0].Low}" + Environment.NewLine); report.Append($"The average high: {daysForReport.GetAverageHighTempForYear():F}" + Environment.NewLine); report.Append($"The average low: {daysForReport.GetAverageLowTempForYear():F}" + Environment.NewLine); report.Append( $"Number of days with temp {this.upperBound} or greater: {daysForReport.GetDaysWithTempGreaterThanEqualTo(this.upperBound)}" + Environment.NewLine); report.Append( $"Number of days with temp {this.lowerBound} or less: {daysForReport.GetDaysWithTempLessThanEqualTo(this.lowerBound)}" + Environment.NewLine); }