light.java

来自「Head first design pattern这本经典书的 源码」· Java 代码 · 共 35 行

JAVA
35
字号
package headfirst.command.undo;public class Light {	String location;	int level;	public Light(String location) {		this.location = location;	}	public void on() {		level = 100;		System.out.println("Light is on");	}	public void off() {		level = 0;		System.out.println("Light is off");	}	public void dim(int level) {		this.level = level;		if (level == 0) {			off();		}		else {			System.out.println("Light is dimmed to " + level + "%");		}	}	public int getLevel() {		return level;	}}

⌨️ 快捷键说明

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