0

I'm writing a spelling bee game and I need help. It is such that when the user clicks a button, a sound file plays and a text field is provided for the user to spell the word pronounced in the sound file. After which the user confirms with a button!!! If the text entered matches that of the sound file, the user is correct. Else, the user is false... I created a file array with 50 contents and a string array with 50 contents... I want to link them in that manner...any Ideas please!! I am a new comer here!

3
  • I suggest you break this down into smaller parts. For example, you need to 1. Create the visual UI with the text field and button. 2. Read a file. 3. Play a sound. Figure out what other small tasks you need to accomplish and attempt to figure out how to do each one. When you have a specific problem with any step, please feel free to ask more questions. Commented Aug 30, 2016 at 23:29
  • Yea.... I'm at the point where I have to link the File array[50] with the String Array[50] such that when the user puts in an answer..... and the String element matches the file element....he/she is correct. If not, he / she is wrong. @Code-Apprentice Commented Aug 30, 2016 at 23:50
  • Please show us what you have tried and explain, in detail, what difficulty you have encountered. Commented Aug 31, 2016 at 0:10

1 Answer 1

1

First you build you arrays in such a way that the sound at element x in your file array matches the word in your string array at element x. When you play the sound, save the index of its element in the array. When the user enters a word, check if its in your string array, if yes, check if its index matches the index of the sound file, if yes, the word they spelled was correct.

//The index of the sound and input from user
int soundToPlay;
String input;

Private int findStringIndex(String input){
  for(int i = 0; i < yourStringArray.length; i++){
    if(yourStringArray[i].equals(input){
      return i;
    }
  }
//not sure if java will allow you to send null like this. If not, you will have to find another way to deal with a string that isnt in your array
return null;
}

private void findMatch(int soundToPlay, String input){
  int index = findStringIndex(input);
  if(index == null){
    //String not in array, notify user
  }
  if(index == soundToPlay){
    //match found, notify user, play next sound
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Exactly what I had in mind, but can you give me a syntax or something..... I 'll be grateful.
@Presh_K7 Im going to need more information then that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.