Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Random;
- public class CubeBooleanScouts {
- public static void main(String[] args)
- {
- final int CUBE_SIZE = 6;
- Random r = new Random();
- int current = 0;
- boolean[] cube = new boolean[CUBE_SIZE];
- boolean found = false;
- for(int i = 0; i < CUBE_SIZE; i++)
- cube[i] = false;
- while(!found)
- {
- current = 1 + (r.nextInt(6));
- if(cube[current - 1])
- found = true;
- else
- cube[current - 1] = true;
- }
- System.out.printf("The winning number is %d.", current);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement