001package headfirst.command.party;
002
003public class Light {
004        String location;
005        int level;
006
007        public Light(String location) {
008                this.location = location;
009        }
010
011        public void on() {
012                level = 100;
013                System.out.println("Light is on");
014        }
015
016        public void off() {
017                level = 0;
018                System.out.println("Light is off");
019        }
020
021        public void dim(int level) {
022                this.level = level;
023                if (level == 0) {
024                        off();
025                }
026                else {
027                        System.out.println("Light is dimmed to " + level + "%");
028                }
029        }
030
031        public int getLevel() {
032                return level;
033        }
034}