currentconditionsdisplay.java

来自「深入浅出设计模式」· Java 代码 · 共 24 行

JAVA
24
字号
package headfirst.observer.weather;	public class CurrentConditionsDisplay implements Observer, DisplayElement {	private float temperature;	private float humidity;	private Subject weatherData;		public CurrentConditionsDisplay(Subject weatherData) {		this.weatherData = weatherData;		weatherData.registerObserver(this);	}		public void update(float temperature, float humidity, float pressure) {		this.temperature = temperature;		this.humidity = humidity;		display();	}		public void display() {		System.out.println("Current conditions: " + temperature 			+ "F degrees and " + humidity + "% humidity");	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?