Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2008, 01:43 AM
Member
 
Join Date: Dec 2008
Posts: 4
Rep Power: 0
kosok is on a distinguished road
Default [SOLVED]Alphabet timer help.
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.

Last edited by kosok; 12-24-2008 at 07:06 PM. Reason: solved
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-24-2008, 03:22 AM
Senior Member
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 473
Rep Power: 2
mtyoung is on a distinguished road
Default
secondTime=second-first;
secondTime always equals 0
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-24-2008, 07:05 PM
Member
 
Join Date: Dec 2008
Posts: 4
Rep Power: 0
kosok is on a distinguished road
Default
solved, I put the getWhens into an array for each letter
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to implement a timer Nuluvius New To Java 11 01-16-2009 02:27 AM
Listing the alphabet (beginner) SuperOnion New To Java 3 12-22-2008 04:23 AM
EJB Timer mrjunsy Advanced Java 0 08-22-2008 05:09 PM
EJB Timer mrjunsy New To Java 0 08-04-2008 07:47 PM
How to cancel an individual timer in spite of canceling whole timer Java Tip java.util 0 04-04-2008 03:46 PM


All times are GMT +2. The time now is 03:01 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org