static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionDisplay currentConditionDisplay = new CurrentConditionDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); CurrentConditionDisplay currentConditionDisplay2 = new CurrentConditionDisplay(weatherData); weatherData.SetMeasurements(70, 65, 30.4f); Console.ReadKey(); }
static void Main(string[] args) { // Create new weather station object WeatherData weatherData = new WeatherData(); // Create new displays and attach them to the new station in the constructor CurrentConditionDisplay currentDisplay = new CurrentConditionDisplay(weatherData); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData); // Update the weather weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); // Detach ForecastDisplay weatherData.Detach(forecastDisplay); // Update should now exclude the forecast text weatherData.SetMeasurements(78, 90, 29.2f); Console.Read(); }
static void Main(string[] args) { SpecifedWeatherData weatherData1 = new SpecifedWeatherData(); SpecifedWeatherData weatherData2 = new SpecifedWeatherData(); SpecifedWeatherData weatherData3 = new SpecifedWeatherData(); SpecifedWeatherData weatherData4 = new SpecifedWeatherData(); CurrentConditionDisplay currentDisplay2 = new CurrentConditionDisplay(weatherData1); // ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData1); weatherData1.SetAllMeasurements(25, 65, 1012, 25, 30); // Console.WriteLine("||||||||||||||||||||||"); weatherData2.SetMeasurements(28, 70, 1006); weatherData3.SetAllMeasurements(23, 90, 1000, 25, 30); WeatherDataStation station1 = new WeatherDataStation("Krakow", "50.0647° N, 19.9450° E"); WeatherDataStation station2 = new WeatherDataStation("Katowice", "50.0647° N, 19.9450° E"); WeatherDataStation station3 = new WeatherDataStation("Katowice", "50.0647° N, 19.9450° E"); station1.Push(weatherData1); station1.Push(weatherData2); station1.Push(weatherData3); //weatherData4.SetMeasurements(130, 60, 1012); MainStation motherstation = new MainStation("StacjaGłówna"); motherstation.AddWeatherStationToMainStation(station1); motherstation.AddWeatherStationToMainStation(station2); motherstation.SaveDataStationtoJSON(); //Console.WriteLine(station1); ///Console.WriteLine(station2); ///Console.WriteLine(station3); WeatherDataStationObserver provider = new WeatherDataStationObserver(); StatisticStationReporter reporter1 = new StatisticStationReporter("FixedGPS"); reporter1.Subscribe(provider); StatisticStationReporter reporter2 = new StatisticStationReporter("MobileGPS"); //reporter2.Subscribe(provider); // provider.TrackWeatherStation(station1); reporter1.Unsubscribe(); //provider.TrackWeatherStation(station2); provider.TrackWeatherStation(null); provider.EndTransmission(); station1.SaveDataStationtoJSON(); station3 = WeatherDataStation.LoadDataStationJSON("Krakow.json"); weatherData1.SaveDatatoJSON("test.json"); weatherData4 = SpecifedWeatherData.OdczytajJSON("test.json"); //Console.WriteLine("|||||||||||"); //Console.WriteLine(weatherData4); //Console.WriteLine("|||||||||||"); //Console.WriteLine(station3); //Console.WriteLine("|||||||||||comparator"); //station1.TemperatureCalsiusSort(true); //Console.WriteLine(station1); //Console.WriteLine("|||||||||||comparatorfalse"); //station1.TemperatureCalsiusSort(); //Console.WriteLine(station1); Console.ReadLine(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("OpenWeatherAPI Example Application"); Console.WriteLine(); Console.WriteLine("Виберіть місто для перегляду погоди:"); //var city = Console.ReadLine(); string city1 = "Hrebinka"; string city2 = "Kiev"; string city3 = "London"; Console.WriteLine(); WeatherCity weather1 = new WeatherCity(city1); WeatherCity weather2 = new WeatherCity(city2); WeatherCity weather3 = new WeatherCity(city3); //створюємо Subject WeatherData sinopticUa = new WeatherData(); //створюємо Observers CurrentConditionDisplay display1 = new CurrentConditionDisplay(); StatisticsDisplay display2 = new StatisticsDisplay(); ForecastDisplay display3 = new ForecastDisplay(); //підписуємо підписників на sinopticUa sinopticUa.EventWeather += display1.OnNext; sinopticUa.EventWeather += display2.OnNext; sinopticUa.EventWeather += display3.OnNext; sinopticUa.EventWeather += new Action <WeatherCity>((new ForecastDisplay()).OnNext); //sinopticUa.EventWeather += x=> { new WeatherCity("Lviv"); }; //Змінюємо показники погоди sinopticUa.SetMeasuremants(weather1); //Розсилаємо погоду sinopticUa.Notify(); sinopticUa.SetMeasuremants(weather2); sinopticUa.Notify(); sinopticUa.SetMeasuremants(weather3); sinopticUa.Notify(); Console.WriteLine(); display2.canUse = false; // display2 відписується від sinopticUa sinopticUa.EventWeather -= display1.OnNext; // sinopticUa відписує display1 sinopticUa.Notify(); //запишемо погоду в файл WeatherCreator creator = new WeatherCreator(); creator.SaveToFile(weather3 as IWeatherCity, @"D:\WeatherCity.txt"); List <IWeatherCity> arr = creator.ReadFromFile(@"D:\WeatherCity1.txt"); Console.ReadLine(); DAOWeather weather = new DAOWeather("myDB2"); weather.PrintConnectionInfo(); Console.WriteLine(); }