        // A class that extends the facilities of its super class,
        // HeaterController, to add temperature-level setting.
class VariableLevelController extends HeaterController {
    // Class constants for basic temperatures.
    public static final int DefaultLevel = 16,
                            MinLevel = 5, MaxLevel = 30;

    public VariableLevelController(int level)
                        throws HeaterLevelException {
        setLevel(level);
    }

    public VariableLevelController(){
    }
    
        // An accessor for the attached heater's current
        // temperature level.
    public int getLevel(){
        // The device keeps track of its current temperature setting.
        return getHeater().getTemperature();
    }

        // Set the heater's level within an allowed range.
    public void setLevel(int level) throws HeaterLevelException {
        if((MinLevel <= level) && (level <= MaxLevel)){
            // Adjust the heater.
            getHeater().setTemperature(level);
        }
        else{
            // The value is out of the allowed range.
            throw new HeaterLevelException("Illegal level setting: "+level);
        }
    }
}
