public class MathProblem extends Enemy
{
/**
* Act - do whatever the MathProblem wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int a = Greenfoot.getRandomNumber(10);
int b = Greenfoot.getRandomNumber(10);
int correct = a + b;
int incorrect = Greenfoot.getRandomNumber(20);
public MathProblem()
{
}
public void act()
{
randomProblem();
}
public void randomProblem()
{
setImage(new GreenfootImage("What is " + a + "+" + b, 50, Color.WHITE, Color.BLACK));
}
public void randomCorrect()
{
setImage(new GreenfootImage(correct + "", 50, Color.WHITE, null));
}
public void randomIncorrect()
{
setImage(new GreenfootImage(incorrect + "", 50, Color.WHITE, null));
}
