001package headfirst.command.undo;
002
003public class DimmerLightOffCommand implements Command {
004        Light light;
005        int prevLevel;
006
007        public DimmerLightOffCommand(Light light) {
008                this.light = light;
009                prevLevel = 100;
010        }
011
012        public void execute() {
013                prevLevel = light.getLevel();
014                light.off();
015        }
016
017        public void undo() {
018                light.dim(prevLevel);
019        }
020}