You also use the Random class...
You also use the Random class:
Random randNum = new Random();
myRandomNum= randNum.nextInt(n);//Returns an int value between 0 (inclusive) and the specified value (exclusive)
OK... here's something I just thought of
Maybe you could do something with three boolean variables:
- boolean bDoor1,bDoor2,bDoor3 = false;
once you know the prize door, just set the cooresponding boolean variable to true.
Use the same logic as before:
- Generate random number
- check against boolean variables
- if false, can be used/assigned
- if true, generate another random number