I'm creating a program that times the user on how fast they can enter the alphabet. I also want to tell the user between which two letters the greatest time gap was. The method i'm trying now involves taking the difference, and then at next keyevent takes the difference of the two differences and only stores the greater one.
here is the code i'm trying:
|
Code:
|
if(first==0)
{
first=ke.getWhen();
System.out.println("Initial first: "+first);
}
else
{
second=ke.getWhen();
System.out.println("Initial second: "+second);
}
if(second!=0 && time==0)
{
time=second-first;
System.out.println("Initial time: "+time);
}
if(time!=0 && secondTime==0)
{
buffer=second;
second=ke.getWhen();
first=buffer;
secondTime=second-first;
System.out.println("Second time: "+secondTime);
}
if(secondTime>time)
{
time=secondTime;
secondTime=0;
System.out.println("Time again "+time);
} |
ke is my KeyEvent, and all my variables are long with initial value of 0.