package NO2;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Yogurt on 16/7/24.
 */
public class WeatherData implements Subject {
    private ArrayList<Observer> observers;
    private float temperature;
    private float humidity;
    private float pressure;

    public WeatherData(){
        observers=new ArrayList<>();
    }
    @Override
    public void registerObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void unRegisterObserver(Observer observer) {
        int index=observers.indexOf(observer);
        if (index>=0) observers.remove(index);
    }

    @Override
    public void notifyObservers() {
        for (int i=0;i<observers.size();i++){
            Observer observer=observers.get(i);
            observer.update(temperature,humidity,pressure);
        }
    }

    public void measurementChanged(){
        notifyObservers();
    }

    public void setMeasurements(float temperature,float humidity,float pressure){
        this.temperature=temperature;
        this.humidity=humidity;
        this.pressure=pressure;
        measurementChanged();
    }
}

@@ -1137,11 +1137,81 @@
 );%0A    %7D
+%0A%0A    public float getPressure() %7B%0A        return this.pressure;%0A    %7D
 %0A%7D%0A

Add getPressure