<<My Program
Card
Deck
Hand
ImagePanel
OFImage
Play
Player
Table
|
Java Code
This is an explanation of the classes I used in the creation of this program.
Card
Card is a class used to keep track of the individual cards used in this game. Each player holds two cards, there are nine possible cards on the table (two for each player and five possible community cards), the deck has fifty-two cards, and a poker hand is made up of five cards.
Fields
rank, suit, cardName, cardImage
rank
An int between 0-12. A 0 is a two, a 1 is a three, . . . , and 12 is an ace.
suit
An int between 0-3. The suit represented is in alphabetical order, so 0 means clubs, 1 means diamonds, 2 means hearts, and 3 means spades.
cardName
Used to retrieve the card image. Must be a rank (number 2-9 or a lower-case character t,j,q,k,a) followed by a suit (c,d,h,s). If you pass "2d" as a card name the image retrieved by getImage() will be a picture of the two of diamonds.
cardImage
An image of the card.
Constructors
Card()
Creates a card with random suit, random rank, and the image of the back of a playing card.
Creates a card with the passed rank, suit, and creates an sets cardImage to the image based on the cardName.
Methods
getRank(), getSuit(), getName(), getImage()
getRank()
Returns the rank of this card. Used frequently in Hand to determine the strength of a five card hand.
getSuit()
Returns the suit of this card. Used in Hand to check for flushes.
getName()
Returns cardName.
getImage()
Returns cardImage.
<<back to top
Deck
Fields
deck
An arraylist of all of the cards in the deck.
Constructors
deck()
Sets deck to an arraylist including all 52 cards. Used in Play when starting a new hand.
Methods
getCard()
Returns one card from deck at random.
<<back to top
Hand
Hand is used to identify the best five card hand out of the seven cards available to each player at a showdown.
Static Fields
HIGHCARD, ONEPAIR, TWOPAIR, SET, STRAIGHT, FLUSH, FULLHOUSE, QUADS, STRAIGHTFLUSH, ROYALFLUSH.
HIGHCARD = 0
ONEPAIR = 1
TWOPAIR = 2
SET = 3
STRAIGHT = 4
FLUSH = 5
FULLHOUSE = 6
QUADS = 7
STRAIGHTFLUSH = 8
ROYALFLUSH = 9
Fields
hand, handType, suit, rank, flush, fullHouse, quadKickers, pairs, c1, c2, c3, c4, c5, x2, x2, straight, quads, set, numberOfPairs, isStraightFlush, isQuads, isFull, isFlush, isStraight, isSet.
Constructors
Hand(Card[] hand)
Evaluates the best five card hand out of the given array of seven cards.
Methods
getHandType(), getQuadKicker(), getFullHouseScore(), getFlushScore(), getSetKicker(), getTwoPairScore(), getOnePairScore(), getHighCardScore().
<<back to top
ImagePanel
An extension of JComponent, this was a class used in an assignment to create an image viewer (Java with BlueJ). It works well for adding an OFImage to a frame.
<<back to top
OFImage
This is a simplified extension of BufferedImage taken from my class exercise from Java with BlueJ. Used to load images of the table, and cards.
<<back to top
Play
To actually play the game, create a new object of type play. This object will be constructed with a frame that has all of the components hooked up correctly to play heads up No Limit Texas Hold 'Em.
<<back to top
Player
Player is used to represent either you or your opponent. It keeps track of how much you have bet, how many chips you have, and what cards you hold.
<<back to top
Table
An extension of ImagePanel, table is a JComponent that displays the current state of the game.
<<back to top
|