Question: Program a game of texas holdem IN JAVA. include inheritance with provided classes (DeckOfCards, Card) public class DeckOfCards { private static final String[] faces =
Program a game of texas holdem IN JAVA.
include inheritance with provided classes (DeckOfCards, Card)
public class DeckOfCards
{
private static final String[] faces =
{"Ace", "Deuce", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
private static final String[] suits =
{"Hearts", "Diamonds", "Clubs", "Spades"};
private static final int NUMBER_OF_CARDS = 52; // constant number of cards
private ArrayList deck= new ArrayList(); // array of Card objects
// constructor fills deck of cards
public DeckOfCards()
{
// populate deck with Card objects
for (int count = 0; count
deck.add( new Card(count%13+1, faces[count % 13], suits[count / 13]));
}
public String toString() {
String ans = "";
for (int i=0;i
ans = ans +deck.get(i).toString() + " ";
return ans;
}
// shuffle deck of cards with one-pass algorithm
public void shuffle()
{
Collections.shuffle(deck);
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------
public class Card {
private String face; // face of card
private String suit; // suit of card
private int value; // 1 to 13 for value
// constructor
public Card(int num,String cardFace, String cardSuit) {
face = cardFace; // initialize face of card
suit = cardSuit; // initialize suit of card
value = num;
}
// return String representation of Card
public String toString() {
return value + ":" + face + " of " + suit;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public String getSuit() {
return suit;
}
public void setSuit(String suit) {
this.suit = suit;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
} // end class Card
------------Logic-----------------------
Royal Flush five cards of the same suit, ranked ace through ten; e.g., 
![classes (DeckOfCards, Card) public class DeckOfCards { private static final String[] faces](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f13d175c2e7_84766f13d174b34c.jpg)

!["Queen", "King"}; private static final String[] suits = {"Hearts", "Diamonds", "Clubs", "Spades"};](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f13d17e0820_84766f13d17cfa29.jpg)

Straight Flush five cards of the same suit and consecutively ranked; e.g., 


![13], suits[count / 13])); } public String toString() { String ans =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f13d1929073_84966f13d19180bb.jpg)

Four of a Kind four cards of the same rank; e.g., 




Full House three cards of the same rank and two more cards of the same rank; e.g., 




Flush any five cards of the same suit; e.g., 




Straight any five cards consecutively ranked; e.g., 




Three of a Kind three cards of the same rank; e.g., 




Two Pair two cards of the same rank and two more cards of the same rank; e.g., 




One Pair two cards of the same rank; e.g., 




High Card five unmatched cards; e.g., 



would be called "ace-high"
In hold'em each player is dealt two cards face down (the "hole cards"), then over the course of subsequent rounds five more cards are eventually dealt face up in the middle of the table. These face up cards are called the "community cards" because each player uses them to make a five-card poker hand.
The five community cards are dealt in three stages. The first three community cards are called the "flop." Then just one card is dealt, called the "turn." Finally one more card, the fifth and final community card, is dealt the "river."
Players construct their five-card poker hands using the best available five cards out of the seven total cards (the two hole cards and the five community cards). This can be done by using both of the hole cards in combination with three community cards, one hole card in combination with four community cardsm or no hole cards and playing all five community cards whatever works to make the best five-card hand.
If the betting causes all but one player to fold, the lone remaining player wins the pot without having to show any cards. For that reason, players don't always have to hold the best hand to win the pot. It's always possible a player can "bluff" and get others to fold better hands. If two or more players make it all of the way to the showdown after the last community card is dealt and all betting is complete, then the only way to win the pot is to have the highest-ranking five-card poker hand.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
