Exemple #1
0
        static void Main()
        {
            var provider  = new WeatherSupplier();
            var observer1 = new WeatherMonitor("TP");
            var observer2 = new WeatherMonitor("H");

            provider.WeatherConditions(32.0, 0.05, 1.5);
            observer1.Subscribe(provider);
            provider.WeatherConditions(33.5, 0.04, 1.7);
            observer2.Subscribe(provider);
            provider.WeatherConditions(37.5, 0.07, 1.2);
        }
Exemple #2
0
        public WeatherStationSimulator()
        {
            this.minuteDayChangeMonitor = new MinuteDayChangeMonitor(
                new DateTimeSourceSimulator(),
                new MinuteDayChangeMonitorStrategy());

            this.outdoorWeatherMonitor = new WeatherMonitor(
                new WeatherSimulator(),
                new WeatherMonitorStrategy());

            this.indoorWeatherMonitor = new WeatherMonitor(
                new WeatherSimulator(),
                new WeatherMonitorStrategy());
        }
Exemple #3
0
        static void Main(string[] args)
        {
            WeatherData weatherData = new WeatherData();
            CurrentConditionsDisplay currentDisplay  = new CurrentConditionsDisplay(weatherData);
            ForecastDisplay          forecastDisplay = new ForecastDisplay(weatherData);

            weatherData.setMeasurements(1, 2, 3f);
            weatherData.setMeasurements(2, 3, 4f);
            weatherData.setMeasurements(30, 4, 5f);


            WeatherMonitor   monitor = new WeatherMonitor();
            CurrentCondition condit  = new CurrentCondition();

            condit.Subscribe(monitor);
            monitor.SetWeatherMonitor(23, 80, 1000);
        }
Exemple #4
0
        public WeatherStation()
        {
            this.minuteDayChangeMonitor = new MinuteDayChangeMonitor(
                new DateTimeSource(),
                new MinuteDayChangeMonitorStrategy());

            //TODO:
            this.outdoorWeather = new CdyneWeatherAdapter();
            //this.outdoorWeather = new NdfdWeatherAdapter();

            this.outdoorWeatherMonitor = new WeatherMonitor(
                this.outdoorWeather,
                new WeatherMonitorStrategy());

            this.indoorWeather        = new WeatherSimulator();
            this.indoorWeatherMonitor = new WeatherMonitor(
                this.indoorWeather,
                new WeatherMonitorStrategy());
        }
        public static void Main(string[] args)
        {
            WeatherMonitor monitor = new WeatherMonitor();
            ForecastDisplay forecast = new ForecastDisplay();
            CurrentConditionsDisplay currentConditions = new CurrentConditionsDisplay();
            StatisticsDisplay statistics = new StatisticsDisplay();
            HeatIndexDisplay heatIndex = new HeatIndexDisplay();

            monitor.SetMeasurments(new WeatherData(80, 65, 30.4f));
            forecast.Subscribe(monitor);
            currentConditions.Subscribe(monitor);
            statistics.Subscribe(monitor);
            heatIndex.Subscribe(monitor);
            monitor.SetMeasurments(new WeatherData(82, 70, 29.2f));
            statistics.Unsubscribe();
            monitor.SetMeasurments(new WeatherData(78, 90, 29.2f));
            monitor.SetMeasurments(null);
            //weatherData.SetMeasurments(82, 70, 29.2f);
            //weatherData.SetMeasurments(78, 90, 29.2f);
            Console.ReadLine();
        }