Пример #1
0
        static void Main(string[] args)
        {
            // create the subject and observers
            WeatherData weatherData = new WeatherData();

            CurrentConditions conditions = new CurrentConditions(weatherData);
            Statistics        statistics = new Statistics(weatherData);
            Forecast          forecast   = new Forecast(weatherData);

            // create the readings
            WeatherMeasurements readings = new WeatherMeasurements();

            readings.humidity    = 40.5F;
            readings.pressure    = 20F;
            readings.temperature = 72F;

            // update the readings - everyone should print
            weatherData.UpdateReadings(readings);

            // update
            readings.pressure = 10F;
            weatherData.UpdateReadings(readings);

            // update
            readings.humidity    = 100;
            readings.temperature = 212.75F;
            readings.pressure    = 950;
            weatherData.UpdateReadings(readings);

            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            // create the subject and observers
            WeatherData weatherData = new WeatherData();

            CurrentConditions conditions = new CurrentConditions(weatherData);
            Statistics statistics = new Statistics(weatherData);
            Forecast forecast = new Forecast(weatherData);

            // create the readings
            WeatherMeasurements readings = new WeatherMeasurements();
            readings.humidity = 40.5F;
            readings.pressure = 20F;
            readings.temperature = 72F;

            // update the readings - everyone should print
            weatherData.UpdateReadings(readings);

            // update
            readings.pressure = 10F;
            weatherData.UpdateReadings(readings);

            // update
            readings.humidity = 100;
            readings.temperature = 212.75F;
            readings.pressure = 950;
            weatherData.UpdateReadings(readings);

            Console.ReadLine();
        }
Пример #3
0
 public void Update(object subject, WeatherMeasurements newReadings)
 {
     if (subject is WeatherData)
     {
         this.readings = newReadings;
         Display();
     }
 }
 public void Update(object subject, WeatherMeasurements newReadings)
 {
     if (subject is WeatherData)
     {
         this.readings = newReadings;
         Display();
     }
 }
Пример #5
0
 public void UpdateReadings(WeatherMeasurements newReadings)
 {
     this.readings = newReadings;
     Change();
 }
Пример #6
0
 public void UpdateReadings(WeatherMeasurements newReadings)
 {
     this.readings = newReadings;
     Change();
 }