-
Notifications
You must be signed in to change notification settings - Fork 0
/
CurrentConditionsDisplay.h
40 lines (33 loc) · 978 Bytes
/
CurrentConditionsDisplay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CURRENT_CONDITIONS_DISPLAY
#define CURRENT_CONDITIONS_DISPLAY
#include "Observer.h"
#include "DisplayElement.h"
#include "Subject.h"
#include <iostream>
#include <memory>
class CurrentConditionsDisplay : public Observer, public DisplayElement {
public:
CurrentConditionsDisplay() = default;
CurrentConditionsDisplay(Subject *wd) : weatherData(wd)
{ weatherData->registerObserver(this); }
void update(double t, double h, double p) override;
void display() const override;
private:
double temperature = 0.0f;
double humidity = 0.0f;
Subject *weatherData = nullptr;
};
inline
void
CurrentConditionsDisplay::update(double t, double h, [[maybe_unused]] double p) {
temperature = t;
humidity = h;
display();
}
inline
void
CurrentConditionsDisplay::display() const {
std::cout << "Current Conditions: " << temperature
<< "F degree and " << humidity << "% humidity\n";
}
#endif /* ifndef CURRENT_CONDITIONS_DISPLAY */