/* * CurrentConditionsDisplay.hpp * * Created on: 31 окт. 2021 г. * Author: alexander */ #pragma once #include "Observer.hpp" #include "DisplayElement.hpp" #include "WeatherData.hpp" class CurrentConditionsDisplay: public Observer, public DisplayElement { private: float temperature; float humidity; WeatherData &weatherData; public: CurrentConditionsDisplay(WeatherData &weatherData) : temperature(0.0), humidity(0.0), weatherData(weatherData) { weatherData.registerObserver(*this); } void update(float temperature, float humidity, float pressure) override { this->temperature = temperature; this->humidity = humidity; display(); } void display() const override { std::cout << "Current conditions: " << temperature << "F degrees and " << humidity << "% humidity" << std::endl; } };