Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // create the subject and observers
            WeatherData weatherData = new WeatherData();

            weatherData.Humidity         = 40.5F;
            weatherData.Pressure         = 20F;
            weatherData.Temperature      = 72F;
            weatherData.PropertyChanged += degis;
            void degis(object sender, PropertyChangedEventArgs e)
            {
                Console.WriteLine("sıcaklık: " + weatherData.Temperature + "basınç: " + weatherData.Pressure + "nem: " + weatherData.Humidity);
            }

            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();
        }