voidflux
Oct 5th, 2004, 05:55 PM
Hello everyone!!
I'm making a poker game, and I need a way to make the dealing randomized, Right now I have a [4][13] array of card objects, and my get function is the following:
I can't have the random numbers be anyting other than
0 to 3 for the columns and 0 to 12 for the rows, because anyhting else will be out of range.
public void getCard(int howMany)
{
Random r = new Random();
while(howMany != 0)
{
int col = r.nextInt(4);
int row = r.nextInt(13);
if (theDeck[col][row].inDeck) {
theDeck[col][row].inDeck = false; //take the card out of the deck
System.out.print(theDeck[col][row].faceType +
theDeck[col][row].cardValue + " ");
--howMany;
}
else
continue;
}
System.out.println();
}
Is there anyway to make this more random?
Thanks!
:afrog:
I'm making a poker game, and I need a way to make the dealing randomized, Right now I have a [4][13] array of card objects, and my get function is the following:
I can't have the random numbers be anyting other than
0 to 3 for the columns and 0 to 12 for the rows, because anyhting else will be out of range.
public void getCard(int howMany)
{
Random r = new Random();
while(howMany != 0)
{
int col = r.nextInt(4);
int row = r.nextInt(13);
if (theDeck[col][row].inDeck) {
theDeck[col][row].inDeck = false; //take the card out of the deck
System.out.print(theDeck[col][row].faceType +
theDeck[col][row].cardValue + " ");
--howMany;
}
else
continue;
}
System.out.println();
}
Is there anyway to make this more random?
Thanks!
:afrog: