I have a separate class called Heater in my project, and I want to display the int value from the tempValue method as text on my world at a location. I want to be able to update the value if the value changes. How would I set up this?
Code:
Heater:
MyWorld:
public class MyWorld extends World
{
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
}
}
public class Heater
{
//temperature variable
int temp;
/**
* Constructor for objects of class Heater
*/
public Heater() {
temp = 15; //initialize temp to 15
}
void warmer() {
this.temp += 5; //add 5 to temp
}
void cooler() {
this.temp -= 5; //subtract 5 from temp
}
public int tempValue() {
return this.temp; //return value of temp
}
}