, 1 99, 10 . , .
1 99 - :
List<Integer> deck = new ArrayList<Integer>();
for( int i=1; i<=99; i++ ){
deck.add( i );
}
Then we need to choose a random card between the 0th card (lists are numbered starting from 0) and the number of elements in the list:
int draw = r.nextRandom( deck.size() );
Integer card = deck.remove( draw );
And repeat this 10 times, doing something with the βmapβ (say, putting it in an array or another list, or something else:
int drawNumbers = new int[10];
for( int co=0; co<10; co++ ){
int draw = r.nextRandom( deck.size() );
Integer card = deck.remove( draw );
drawNumbers[co] = card;
}
source
share