View Single Post
  #4 (permalink)  
Old 12-29-2007, 12:34 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Okay
Let's create a mix method:
Code:
public static String[] mix(String[] array){ Vector<String> data = new Vector<String>(); String[] result = new String[array.length]; for (String string : array) data.add(string); int count = 0; while (data.size() > 0){ int pos = (int)(Math.random() * (double)data.size()); String next = data.get(pos); result[count++] = next; data.remove(pos); } return result; }
Use this method to mix the array before you use it:
Code:
questions = mix(questions);
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote