static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(); ForecastDisplay forecastDisplay = new ForecastDisplay(); HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(); currentDisplay.Subscribe(weatherData); statisticsDisplay.Subscribe(weatherData); forecastDisplay.Subscribe(weatherData); heatIndexDisplay.Subscribe(weatherData); // create the readings WeatherMeasurements readings = new WeatherMeasurements(); readings.Temperature = 80f; readings.Humidity = 65f; readings.Pressure = 30.4f; weatherData.Mesurements(readings); readings.Temperature = 82f; readings.Humidity = 70f; readings.Pressure = 29.2f; weatherData.Mesurements(readings); readings.Temperature = 78f; readings.Humidity = 90f; weatherData.Mesurements(readings); }
public override void OnNext(WeatherMeasurements value) { tempSum += value.Temperature; numReadings++; if (value.Temperature > maxTemp) { maxTemp = value.Temperature; } if (value.Temperature < minTemp) { minTemp = value.Temperature; } Display(); }
public override void OnNext(WeatherMeasurements value) { heatIndex = computeHeatIndex(value.Temperature, value.Humidity); Display(); }
public override void OnNext(WeatherMeasurements value) { lastPressure = currentPressure; currentPressure = value.Pressure; Display(); }
public override void OnNext(WeatherMeasurements value) { this.temperature = value.Temperature; this.humidity = value.Humidity; Display(); }