Hi can somebody please help me,i keep getting the error message that variable start might not have been initialized...here's the program,any help appreciated
import graphics.*;
public class ReactionTester //This program is like a game and measures how long it takes the user to click a circle that appears at a random position
{
public static void main(String [] args)
{
Window win = new Window(750,750); //This is the size of the box that the program will be in
long start;
long stop;
int i = (int)(500 * Math.random()); //This method is used to generate the position of the circle
int r = (int)(75 * Math.random()); //This method is used to generate the size of the circle
int answer;
Circle RandomCircle = new Circle(i,i,r); //This is the method for the circle and what creates the circle
win.draw(RandomCircle); //This draws the random circle
long time;
while(true) //This makes the program wait for the user to click the mouse
{
if(win.isPressed()) //This is will happen after the first click
{
start = System.currentTimeMillis(); //This remembers the current time
}
if(win.isPressed()) //This will happen after the second click
{
stop = System.currentTimeMillis(); //This remembers the current time
Point mouse = win.getMouse(); //This gets the position of the mouse
int x1= mouse.getX(); //This is the x position
int y1 = mouse.getY(); //and this is the y position
answer=(((x1-i)*(x1-i))+((y1-i)*(y1-i))); //This works out if the mouse was clicked inside the circle
if(answer<=(r*r)) //This will happen if they have clicked inside the circle
{
win.erase(RandomCircle); //This erases the circle
System.out.println("It took " + (stop - start) + " milliseconds to click the circle"); //This prints off how long it took to click the circle
}
else if(answer>(r*r)) //This will happen if they havent clicked inside the circle
{
win.draw(RandomCircle); //It just draws another random circle and starts again
}
}
}
}
}