I need to have a Greenfoot.ask() prompt appear after 5 seconds and then go away after the answer is inputted. However, I can't get my timer to work and it won't disappear after answer has been inputted.
public class Calculations extends Actor
{
String questions = {"5/9 times 1/2", "2/3 times 5/7",
"1/2 times 1/3", "5/7 times 7/5",
"3/4 times 1/4", "1/4 times 1/3",
"7/8 times 1/2", "1/4 times 1/4",
"1/2 times 1/2", "3/2 times 1/2",
"1/7 times 2/3", "1/8 times 1/2",
"1/3 times 1/3", "1/5 times 1/5",
"1/2 times 1/6", "1/2 times 1/4"};
String answers = {"5/18", "10/21", "1/6", "1",
"3/16", "1/12", "7/16", "1/16",
"1/4", "3/4", "2/21", "1/16",
"1/9", "1/25", "1/12", "1/8"};
int count;
/**
* Act - do whatever the Calculations wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
int Timer = 6;
if (Timer > 0)
{
Timer--;
}
else if (Timer == 0)
{
Prompt();
}
}
private void Prompt()
{
int index = (int)(Math.random() * 16);
String ianswer = Greenfoot.ask("Question: " + questions);
if (ianswer == answers)
{
Greenfoot.start();
count++;
//correct
}
else
{
//fail
}
}
}