arrays - I need to determine if a random number is unique -
i need write function receives number generated in fillarray , determine if has been generated. need return true or false determining if random number must put array. here's working on. help. i've searched similar unfortunately cannot find anything.
public class randomgenerator {
int arr[] = new int[6]; int size; public void fillarray() { int randnum = (int) (math.random() * 49) + 1; (int = 0; < size; i++) { arr[i] = randnum; alreadythere(randnum); } size++; } public int alreadythere(int randnum) { int find = randnum; boolean found = false; int = 0; while (!found && < size) { if (arr[i] == find) { found = true; } i++; } if (!found) { } return randnum; }
Comments
Post a Comment