• Post Reply Bookmark Topic Watch Topic
  • New Topic

problems with making comparisons  RSS feed

 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making a typing application where random words come on the screen and the user has to enter the words into a text box.
I created the array for the words but I have no idea how to compare these words the the ones entered into the text box by the user.
Also i want the word to change after the user presses enter or when the word has been typed (which ever is easier!)
I only just started learning java so I need all the help I can get

here is the code for my array:
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already have the data in array and the user input. Use a loop that iterates through each element of the array and compares with the user input.
 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you help me with that?
I have never done that kind of code before
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a method like the following, pass the user input to this method, and I assume that that the array is accessible within the method.

 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok but where would i put this code? do i need an event for the textbox thats taking the users input?
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends how you wish to validate. It can be an event on the textbox, or you can have button to validate the input, it completely depends upon how you are designing the user interface.
 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well what i would like the program to do is maybe play a sound everytime the user enters the wrong letter.
and to move onto the next word when they press enter.
at the end a message dialog box would pop saying how many errors you made
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrong letter or wrong word?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!