2011-05-22, 01:18 AM
Please pardon the syntax errors. I don't have Netbeans installed that I can change this.
http://download.oracle.com/javase/6/docs...l/Set.html
The other option is to create a "Deck" singleton object, then have the "Poker" class draw from the Deck object to add unique values. Otherwise you could have multiple players that draw the same card twice. So you could have two different straight heart flushes with the same cards.
So, the Deck class would have the following methods:
public GenerateDeck
public ShuffleCards
public DrawCard
And the following properties:
private cards
Code:
public static Card[] drawPokerHand() {
static final int numCards = 5;
Set pokerValues = new HashSet<Block>();
Card[] pokerHand = new Card[5];
Random gen = new Random();
int randNum;
while(pokerValues.size() + 1 < numCards)
{
randNum = gen.nextInt(52)+1;
pokerValues.add(randNum)
}
//From here take the values from the HashSet and put it in the pokerHand array.
return pokerHand;
}http://download.oracle.com/javase/6/docs...l/Set.html
The other option is to create a "Deck" singleton object, then have the "Poker" class draw from the Deck object to add unique values. Otherwise you could have multiple players that draw the same card twice. So you could have two different straight heart flushes with the same cards.
So, the Deck class would have the following methods:
public GenerateDeck
public ShuffleCards
public DrawCard
And the following properties:
private cards
