Hello fellow programmers, I seem to be having trouble with my code. You see, I have a counter that goes on in "Eating" and "Governor" is a subclass of eating. The counter increments and increases score, and there is a method in "Eating" called "getScore()." It returns the score, and for some reason in the "Governor" class, it is not getting the score, take a look.
(EATING CLASS CODE)
(GOVERNOR CODE)
I thought maybe it's because the "Eating" wasn't in the world, so I made a blank image and set it on "Eating," and spawned eating in the world, and tested to see if it is actually counting, so I got the score, and it returned what it should have been.
I had it where the counter was in the "Governor" class, but that didn't work because each governor had it's own counter, so I made the "Eating" class have one counter that all the "Governors" can reach, but unfortunately it is not.
My main objective is to get all the "Governors" to be gone when the "score" reaches 100, and to set the image of the governor to something else, I don't know if there is anyway to do that, but if there is, tell me!
Thanks programmers! (sorry if some of this seems obscure for I am new to programming)
public void act()
{
counter(); //calls the method
}
private void counter(){ //increments the score
counter += 1; //increments the counter by one
if (counter % 1 == 0) { //everytime counters mod equals 0 it runs this
score++; //increments the score
System.out.print("soup"); //test to see if it is bing reached(it is)
}
}
public int getScore(){ //this gets the score and returns it
return score; //returns score
} public void governorBoss(){
if (getScore() == 101){ //this gets score from the eating class
System.out.println("test"); //to test if the code is being reached (it is not)
setImage(Boss); //this sets image to a bigger governor
}
if (getScore()== 100){ //when score equals 100, run this
getWorld().removeObject(this); //removes object from the world
System.out.println("ssn"); //test to see if the code is being reached (it is not)
}
}

