ceilingfan.java

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

JAVA
43
字号
package headfirst.command.remote;public class CeilingFan {	String location = "";	int level;	public static final int HIGH = 2;	public static final int MEDIUM = 1;	public static final int LOW = 0; 	public CeilingFan(String location) {		this.location = location;	}  	public void high() {		// turns the ceiling fan on to high		level = HIGH;		System.out.println(location + " ceiling fan is on high"); 	} 	public void medium() {		// turns the ceiling fan on to medium		level = MEDIUM;		System.out.println(location + " ceiling fan is on medium");	}	public void low() {		// turns the ceiling fan on to low		level = LOW;		System.out.println(location + " ceiling fan is on low");	} 	public void off() {		// turns the ceiling fan off		level = 0;		System.out.println(location + " ceiling fan is off");	} 	public int getSpeed() {		return level;	}}

⌨️ 快捷键说明

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