i have successfully made to ask the player to input a value. i asked the player to input the answer on the problem given on the game and i assigned a certain value for the correct answer. i tried to answer to see if the program is working and inserted a wrong value, then the try again world appeared. i tried to reset the whole game but when it comes to the ask part, the "try again" automatically appears. how can i reset the input value?
Here is my program.
public double answer;
public double correctans = 57.24;
public void act()
{
ask();
check();
}
public void ask()
{
if (Greenfoot.isKeyDown("enter"))
{
String input = Greenfoot.ask("On which point should the car turn? Round of to 2 decimal places");
answer = Integer.valueOf(input);
}
}
public void check()
{
if (answer == correctans)
{
Greenfoot.setWorld(new congrats());
}
if (answer != correctans)
{
Greenfoot.setWorld(new retry());
}
}