Yay! My first class...
I know it's simple..
/**
* Class to simulate central heating system control.
*
* @author Nick SImpson
* @version 24/12/09
*/
public class heater
{
//-------------------------------------------------------------------
// Fields.
//-------------------------------------------------------------------
private int temperature;
private int maxTemp;
private int minTemp;
private int increment;
//-------------------------------------------------------------------
// Constructors.
//-------------------------------------------------------------------
/**
* Constructor for objects of class heater
*/
public heater(int max, int min, int incr)
{
temperature = 15;
maxTemp = max;
minTemp = min;
increment = incr;
// Prevent negative temperature increments.
if (increment<0 ) {
increment = -increment;
}
}
//-------------------------------------------------------------------
// Methods.
//-------------------------------------------------------------------
/**
* Increase temperature by increment degrees mutator.
*/
public void warmer()
{
temperature += increment;
// Limit temperature to maximum.
if (temperature > maxTemp){
temperature=maxTemp;
}
}
/**
* Decrease temperature by increment degrees mutator.
*/
public void cooler()
{
temperature -= increment;
//Limit temperature to minimum.
if (temperature<minTemp) {
temperature=minTemp;
}
}
/**
* Return the temperature accessor.
*/
public int returnTemp()
{
return temperature;
}
}