I need a code that shows a text if a counter gets set to 0.


if(counter == 0) { System.out.println("Counter was set to 0"); }
public class GoodCounter extends Actor { private int totalCount = 100; public GoodCounter() { setImage(new GreenfootImage("100", 50, Color.ORANGE, Color.BLACK)); } public void bumpCount(int amount) { { totalCount += amount; setImage(new GreenfootImage("" + totalCount, 50, Color.ORANGE, Color.BLACK)); } } }
public void bumpCount(int amount) { totalCount += amount; if(totalCount > 0) { setImage(new GreenfootImage("" + totalCount, 50, Color.orange, Color.black)); } else { setImage(new GreenfootImage("You lose!", 50, Color.orange, Color.black)); } }