-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWeatherData.java
More file actions
40 lines (32 loc) · 1001 Bytes
/
Copy pathWeatherData.java
File metadata and controls
40 lines (32 loc) · 1001 Bytes
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
package WeatherApplicationSimulatorV2;
import java.utils.ArrayList;
import java.utils.Observable; // builtin api
import java.utils.Observer; // builtin api
public class WeatherData extends Observable {
// private ArrayList observers;
private float temperature;
private float humidity;
private float pressure;
public WeatherData() {
// observers = new ArrayList();
}
public void measurementsChanged() {
setChanged(); // to ensure that the state has changed
notifyObservers(); //pull method
}
public void setMeasurements(float temperature, float humidity, float pressure) {
this.temperature = temperature;
this.humidity = humidity;
this.pressure = pressure;
measurementsChanged();
}
public float getTemperature() {
return temperature;
}
public float getHumidity() {
return humidity;
}
public float getPressure() {
return pressure;
}
}