| 15 | "Praline Cream", "Mud Pie" |
| 16 | }; |
| 17 | public static String[] flavorSet(int n) { |
| 18 | if(n > FLAVORS.length) |
| 19 | throw new IllegalArgumentException("Set too big"); |
| 20 | String[] results = new String[n]; |
| 21 | boolean[] picked = new boolean[FLAVORS.length]; |
| 22 | for(int i = 0; i < n; i++) { |
| 23 | int t; |
| 24 | do |
| 25 | t = rand.nextInt(FLAVORS.length); |
| 26 | while(picked[t]); |
| 27 | results[i] = FLAVORS[t]; |
| 28 | picked[t] = true; |
| 29 | } |
| 30 | return results; |
| 31 | } |
| 32 | public static void main(String[] args) { |
| 33 | for(int i = 0; i < 7; i++) |
| 34 | show(flavorSet(3)); |