package edu.miamioh.cse283.htw;

/**
 * Created by Nate on 2014-11-18.
 */
public class Utils {
	public static int random(int high) {
		return (int) (Math.random() * high);
	}

	public static int random(int low, int high) {
		return (int) (Math.random() * (high - low)) + low;
	}
}

@@ -26,16 +26,43 @@
 3.htw;%0A%0A
+import java.util.HashSet;%0A%0A
 /**%0A * C
@@ -299,11 +299,892 @@
  low;%0A%09%7D
+%0A%0A%09/**%0A%09 * Returns an array containing n unique random ints i such that low %3C= i %3C high. If high-low %3C n, an exception will be thrown.%0A%09 *%0A%09 * @param n    number of random elements to generate%0A%09 * @param low  bottom of range of elements to be generated (inclusive)%0A%09 * @param high top of range of elements to be generated (exclusive)%0A%09 * @return array containing n random ints i such that low %3C= i %3C high%0A%09 */%0A%09public static int%5B%5D nRand(int n, int low, int high) %7B%0A%09%09if (high - low %3C n)%0A%09%09%09throw new IllegalArgumentException(%22n must be larger than range of random values%22);%0A%0A%09%09int%5B%5D rand = new int%5Bn%5D;%0A%09%09HashSet%3CInteger%3E used = new HashSet%3CInteger%3E();%0A%0A%09%09for (int i = 0; i %3C n; i++) %7B%0A%09%09%09int choice;%0A%09%09%09while (used.contains(choice = random(low, high))) %7B%0A%09%09%09%7D%0A%09%09%09rand%5Bi%5D = choice;%0A%09%09%7D%0A%0A%09%09return rand;%0A%09%7D%0A%0A%09public static int%5B%5D nRand(int n, int high) %7B%0A%09%09return nRand(n, 0, high);%0A%09%7D
 %0A%7D%0A

add nRand method to utils to generate random arrays