View Single Post
  #13 (permalink)  
Old 01-21-2008, 07:15 PM
mcal mcal is offline
Member
 
Join Date: Jan 2008
Posts: 39
mcal is on a distinguished road
Hi, i'm really sorry but i got stuck with an other problem. As you have told me previously, the method of random i have used isn't so efficient since it is displayin some of the question repetively. Is there another way, how i could generate the questions randomly without displaying some of the questions over again? Thanks a lot. I'm really obliged.

Code:
public void askQuestions(String[] questions, String[] answers) { int count = 0; int point = 0; for(int j = 0; j < questions.length; j++) { Random generator = new Random(); int randomIndex = generator.nextInt(questions.length); String input = JOptionPane.showInputDialog(null, questions[randomIndex]); if(answers[randomIndex].equalsIgnoreCase(input)) count++; // incrementing counter if entered answer is correct point++; if(!timeForMore) break; }

Last edited by mcal : 01-21-2008 at 08:06 PM.
Reply With Quote