All Packages Class Hierarchy This Package Previous Next Index
Class com.lotspiech.poker.Deck
java.lang.Object
|
+----com.lotspiech.poker.BunchOfCards
|
+----com.lotspiech.poker.Deck
- public class Deck
- extends BunchOfCards
This class represents a deck of cards, possibly including one or more
jokers. It can perform all the combinatoric calculations on the cards
in the deck.
Copyright 2001, 2002 by Jeffrey B. Lotspiech. This program is open source;
it is licensed under the Common Public License Version 0.5.
- Author:
- Jeffrey B. Lotspiech
- See Also:
- Card
-
COPYRIGHT
-
-
deck
-
-
random
-
-
Deck(int, int)
- Creates a deck of cards.
-
comb(int, int)
- Returns combinatorial of a take b.
-
countOther(int, int)
- Returns the number of different ways the a given draw
could be filled from the current deck.
-
countRank(int, int)
- Returns the number of ways of drawing cards of given rank.
-
countSuit(int, int, int)
- Returns the number of ways of drawing cards of given suit.
-
countWilds(int)
- Returns the number of ways of drawing a given number of wild cards.
-
deal(int)
- Deals a given number of cards out of the deck.
-
getNumberOfHands()
- This returns the total number of five-card hands that
can be dealt from this deck.
-
getSingletonCalculator(int[], int)
- This returns a SingletonCalculator for the remaining cards
in the deck.
-
getStraightCalculator(int, int[], int, int)
- This method returns a straight calculator for straight flushes in
a given hand.
-
getStraightCalculator(int[], int, int)
- This returns a calculator for normal straight calculations.
-
removeCard(Card)
- This removes a card from the deck, overriding the
BunchOfCards method.
-
shuffle()
- Guess what, this produces a random order of the deck.
COPYRIGHT
private static final String COPYRIGHT
deck
private Card deck[]
random
private Random random
Deck
public Deck(int decksize,
int wildRank)
- Creates a deck of cards.
comb
private static int comb(int a,
int b)
- Returns combinatorial of a take b.
countOther
public int countOther(int remove,
int draw)
- Returns the number of different ways the a given draw
could be filled from the current deck. Wild cards are
never counted by this method.
- Parameters:
- remove - Consider this number of additional cards not in the deck.
- draw - Number of cards to be drawn.
- Returns:
- The number of ways.
countRank
public int countRank(int rank,
int need)
- Returns the number of ways of drawing cards of given rank.
- Parameters:
- The - rank to be drawn.
- The - number of cards of that rank needed.
- Returns:
- the number of ways of drawing 'need' cards of 'rank' rank
from the cards left in the deck.
countSuit
public int countSuit(int suit,
int need,
int missing)
- Returns the number of ways of drawing cards of given suit.
- Parameters:
- suit - The suit to be drawn.
- need - The number of cards of that suit needed.
- missing - Consider that this number of additional cards
of that suit are already missing from the deck.
- Returns:
- the number of ways of drawing 'need' cards of 'suit' suit
from the cards left in the deck.
countWilds
public int countWilds(int need)
- Returns the number of ways of drawing a given number of wild cards.
- Parameters:
- need - The number of wild cards needed.
- Returns:
- The number of ways.
deal
public Card[] deal(int ncards) throws Exception
- Deals a given number of cards out of the deck.
- Parameters:
- ncards - The number of cards to be dealt.
- Returns:
- The cards themselves.
getNumberOfHands
public int getNumberOfHands()
- This returns the total number of five-card hands that
can be dealt from this deck.
- Returns:
- The number of hands.
getSingletonCalculator
public SingletonCalculator getSingletonCalculator(int have[],
int maxDraw)
- This returns a SingletonCalculator for the remaining cards
in the deck.
- Parameters:
- have - An array of the counts by rank already in the hand.
- maxDraw - The maximum number of cards that can be drawn for
this calculator. This is allows optimizations.
- Returns:
- The calculator.
getStraightCalculator
public StraightCalculator getStraightCalculator(int have[],
int draw,
int wild)
- This returns a calculator for normal straight calculations.
- Parameters:
- have - An array of the counts by rank already in the hand.
- draw - The number of cards to be drawn.
- wild - The number of wild cards assumed in the hand.
- Returns:
- The calculator.
getStraightCalculator
public StraightCalculator getStraightCalculator(int suit,
int have[],
int draw,
int wild)
- This method returns a straight calculator for straight flushes in
a given hand.
- Parameters:
- suit - The suit of the straight flush.
- have - An array of the count of the cards in that suit and hand by rank.
- draw - The number of cards that will drawn.
- wild - The number of assumed wild cards.
- Returns:
- The calculator.
removeCard
public void removeCard(Card c) throws LogicException
- This removes a card from the deck, overriding the
BunchOfCards method.
- Parameters:
- c - The card.
- Throws: LogicException
- If the specified card is not in the deck.
- Overrides:
- removeCard in class BunchOfCards
shuffle
public void shuffle()
- Guess what, this produces a random order of the deck.
All Packages Class Hierarchy This Package Previous Next Index