All pastes #920530 Raw Edit

Unnamed

public java v1 · immutable
#920530 ·published 2008-02-27 14:08 UTC
rendered paste body
/** * Heater-exercise. * @author Daniel Raban * @version 27.02.08 */public class Heater{    /**    * Field variables.    */    private int temperature;    private int min;    private int max;    private int increment;        /**    * Constructor that initiates the object with the temperature 15    * and sets the min and max values.    */    public Heater(int newMin, int newMax)    {        temperature = 15;        min = newMin;        max = newMax;        increment = 5;    }    /**    * Method that changes the temperatures to value + increment.    */    public void warmer()    {        if (temperature + increment <= max)        {            temperature = temperature + increment;        }        else         {            temperature = max;        }    }    /**    * Method that changes the temperatures to value - increment.    */    public void cooler()    {        if (temperature - increment >= min)        {            temperature = temperature - increment;        }        else         {            temperature = min;        }    }    /**    * Shows the value of the variable temperature.    */    public int getTemperature()    {        return temperature;    }        /**     * Method that changes the Increment value.     */    public void setIncrement(int newIncrement)    {        if (newIncrement > 0)        {            increment = newIncrement;        }            }}