コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 public override void OnNext(WeatherMeasurements value)
 {
     heatIndex = computeHeatIndex(value.Temperature, value.Humidity);
     Display();
 }
コード例 #4
0
 public override void OnNext(WeatherMeasurements value)
 {
     lastPressure    = currentPressure;
     currentPressure = value.Pressure;
     Display();
 }
コード例 #5
0
 public override void OnNext(WeatherMeasurements value)
 {
     this.temperature = value.Temperature;
     this.humidity    = value.Humidity;
     Display();
 }