So I've been working on this robot in Robocode, and I want it to change its color based on the result of the command getEnergy()
However, I can't seem to get it to work. The java code I have created is the following:
getEnergy();
if(getEnergy()>=90)
{
setBodyColor(new Color(0, 255, 0));
}if(getEnergy()<90 && getEnergy()>=40){
setBodyColor(new Color(0, 0, 255));
}if(getEnergy()<40){
setBodyColor(new Color(255, 0, 0));
}
I also tried this:
getEnergy();
if(getEnergy()>=90)
{
setBodyColor(new Color(0, 255, 0));
}else if(getEnergy()>=40){
setBodyColor(new Color(0, 0, 255));
}else if(getEnergy()<40){
setBodyColor(new Color(255, 0, 0));
}
What am I doing wrong?