Created
July 22, 2018 18:46
-
-
Save gayashanbc/456b21f2d16f5cab5d2738ab5fa91947 to your computer and use it in GitHub Desktop.
Implementation file of the main class (Observer Pattern in C++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "WeatherData.hpp" | |
#include "Client.hpp" | |
int main() { | |
WeatherData weatherStation; | |
Client one(1), two(2), three(3); | |
float temp, humidity, pressure; | |
weatherStation.registerObserver(&one); | |
weatherStation.registerObserver(&two); | |
weatherStation.registerObserver(&three); | |
std::cout << "Enter Temperature, Humidity, Pressure (seperated by spaces) << "; | |
std::cin >> temp >> humidity >> pressure; | |
weatherStation.setState(temp,humidity,pressure); | |
weatherStation.removeObserver(&two); | |
std::cout << "\n\nEnter Temperature, Humidity, Pressure (seperated by spaces) << "; | |
std::cin >> temp >> humidity >> pressure; | |
weatherStation.setState(temp,humidity,pressure); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment