I just started coding and can't get this "Heater" object to work. It just prompts the if else statement "its too hot" when trying to give temp a higher value and it does not stop/ goes below the min temp value when calling the "colder" method. Thanks
public class Heater {
private double temp;
private double min;
private double max;
private double increment;
public Heater(double min, double max) {
temp = 15;
increment = 5;
}
public void Warmer() {
if(temp + increment <= max) {
temp = temp + increment;
} else if(temp + increment > max) {
System.out.println("Too hot");
}
}
public void Colder() {
if(temp - increment >= min){
temp = temp - increment;
} else if (temp - increment < min){
System.out.println("Too cold");
}
}
public double getTemp() {
return temp;
}
}