Need Help urgently. We were required to create a game as an assignment given no pre knowledge of Looping structures and Arrays (These are project requirements) in greenfoot. These aspects are to be taught to us after our assignment is given in and as a result of this I find myself experiencing a few problems in creating the program.
The error message appearing on the gui says the following:
"The constructor for the world is taking a long time. You may have an infinite loop."
My code is below. Could anyone point me towards the right direction or perhaps explain what i did incorrectly?
I'd appreciate your help very much!
public Stage1()
{
super(600, 400, 1);
Scanner Kb = new Scanner(System.in);
int[] arrayNums = {0,1,2,3,4,5,6,7,8,9,10,11,12};
for (int i = 0 ; i <= 10 ; i++)
{
int num1 = arrayNums[Greenfoot.getRandomNumber(12)];//get random array num position
int num2 = arrayNums[Greenfoot.getRandomNumber(12)];//get random array num position
JOptionPane.showInputDialog("What is "+num1+" added to "+num2+"?");//prompt for input
int answer = Kb.nextInt();//accepting keyboard input in a variable
int result = num1 + num2;
int points = 0;
if(answer==result)
{
JOptionPane.showMessageDialog(null,"Good Job!","",JOptionPane.INFORMATION_MESSAGE);
points += 1;
}
if(points >=7)
{
JOptionPane.showMessageDialog(null,"You completed this level!Want to go to the next one?","",JOptionPane.INFORMATION_MESSAGE);
int response = +JOptionPane.showConfirmDialog(null, "Do you want to continue to level 2?", "Confirm",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if( response == JOptionPane.YES_OPTION)
{
}
else
{
Greenfoot.stop();
}
}
}
}
}


