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
// | |
// Created by shan on 4/7/17. | |
// | |
#ifndef OBSERVER_PATTERN_SUBJECT_HPP | |
#define OBSERVER_PATTERN_SUBJECT_HPP | |
#include "Observer.hpp" |
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
// | |
// Created by shan on 4/7/17. | |
// | |
#ifndef OBSERVER_PATTERN_OBSERVER_HPP | |
#define OBSERVER_PATTERN_OBSERVER_HPP | |
/** | |
* Interface for the Observer | |
*/ |
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
// | |
// Created by shan on 4/7/17. | |
// | |
#ifndef OBSERVER_PATTERN_WEATHERDATA_HPP | |
#define OBSERVER_PATTERN_WEATHERDATA_HPP | |
#include <vector> | |
#include <algorithm> | |
#include <iostream> |
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
// | |
// Created by shan on 4/7/17. | |
// | |
#include "WeatherData.hpp" | |
void WeatherData::registerObserver(Observer *observer) { | |
observers.push_back(observer); | |
} |
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
// | |
// Created by shan on 4/7/17. | |
// | |
#ifndef OBSERVER_PATTERN_CLIENT_1_HPP | |
#define OBSERVER_PATTERN_CLIENT_1_HPP | |
#include <iostream> | |
#include "Observer.hpp" |
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
// | |
// Created by shan on 4/7/17. | |
// | |
#include "Client.hpp" | |
void Client::update(float temp, float humidity, float pressure) { | |
// print the changed values | |
std::cout << "---Client (" << id << ") Data---\tTemperature: " << temp | |
<< "\tHumidity: " << humidity |
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; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello from AngularJS</title> | |
</head> | |
<body> | |
</body> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello from AngularJS</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"> | |
</script> | |
</head> | |
<body> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello from AngularJS</title> | |
<script src="angular.min.js"></script> | |
</head> | |
<body> | |
</body> |
OlderNewer