-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathWeatherData.java
42 lines (34 loc) · 1.31 KB
/
WeatherData.java
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
41
42
package observer.headfirst.inefficient;
import observer.headfirst.inefficient.CurrentConditionsDisplay;
import observer.headfirst.inefficient.StatisticsDisplay;
import observer.headfirst.inefficient.ForecastDisplay;
public class WeatherData {
private final CurrentConditionsDisplay currentConditionsDisplay;
private final StatisticsDisplay statisticsDisplay;
private final ForecastDisplay forecastDisplay;
public WeatherData() {
this.currentConditionsDisplay = new CurrentConditionsDisplay();
this.statisticsDisplay = new StatisticsDisplay();
this.forecastDisplay = new ForecastDisplay();
}
public void measurementChanged() {
double temp = getTemperature();
double humidity = getHumidity();
double pressure = getPressure();
currentConditionsDisplay.update(temp, humidity, pressure);
statisticsDisplay.update(temp, humidity, pressure);
forecastDisplay.update(temp, humidity, pressure);
}
public double getTemperature() {
// Logic to get temperature from the sensors.
return 32.2;
}
public double getHumidity() {
// Logic to get humidiy from the sensors.
return 10.1;
}
public double getPressure() {
// Logic to get pressure from the sensors.
return 22.2;
}
}