public ForecastDisplay(WeatherData weatherData) { this.weatherData = weatherData; weatherData.RegisterObserver(this); }
//构造器需要weatheData对象(或主题)作为注册用。 public StatisticsDisplay(WeatherData weatherData) { this.weatherData = weatherData; weatherData.RegisterObserver(this); }
public HeatIndexDisplay(WeatherData weatherData) { this.weatherData = weatherData; weatherData.RegisterObserver(this); }