View Single Post
Old 11-12-2012, 03:55 PM   PM User | #1
clue<
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
clue< is an unknown quantity at this point
conditions error

Hi!
I'm very new to javascript and i'm trying to write a script that allows me to:
-add to and substract from a value called temperature through methods warmer and cooler
-read temperature
-set a maximum and minimum value for temperature

this is what i've come up with:
Code:
public class Heater
{
    private int temperature;
    private int min;
    private int max;
    private int increment;
    private int recMin;
    private int recMax;
    
    public Heater()
    {
        temperature = 15;
        min = recMin;
        max = recMax;
        increment = 5;
    }
    
    public void insrtMin(int minimum)
    {
        recMin = minimum;
    }
    
    public void insrtMax(int maximum)
    {
        recMax = maximum;
    }
    
    public void warmer()
    {   
        if ((temperature + increment) > max)
        {

        }
        else
        {
            temperature = temperature + increment;
        }
    }
    
    public void cooler()
    {   
        if ((temperature - increment) < min)
        {

        }
        else
        {
            temperature = temperature - increment;
        }
    }     

    public int returnTemp()
    {
        return temperature;
    }
}
The code worked fine until I added the conditions to 'warmer' and 'cooler'. Now, however, only the cooler method seems to work. What did I miss?

thanks!
clue< is offline   Reply With Quote