int x,y;
if (hit == true) //is the switch on (i.e. was the button pressed)?
{
hit=false; //reset flag (work out why, by seeing what would happen if this line were not here)
for(int i=0; i<number;i++) //print Ouch out the number of times myText in the text box
{
x = (int) (Math.random() * 100)+1; //calculate a random x position
y = (int) (Math.random() * 100)+1; //calculate a random y position
g.drawString("Ouch!!!",20+x+i,20+y+i); //print at the random position
}
}
if (number != 0) //if a number was typed in display it.
{
g.drawString("You typed in " + number,100,125);
}