Menu

[Solved]Java Need Help Implementing Checkplayerhand Playgame Methods Videopoker Class Card Class C Q37103816

Java.
I need help implementing the checkPlayerHand() andplayGame() methods in theVideoPoker class!

import java.util.*; Ref: Short Description and Poker rules Video poker is also known as draw poker. The dealer uses a 52-card

public class VideoPoker // default constant values private static final int defaultBalance 100; private static final int numb

/This display the pavaut table based on winningMultipliers and winningHands arrays private void showPayoutTable() System.out.

/* Check current playerHand using winningMultipliers and winningHands arrays Must print yourHandType (default is Sorry, you

Here is the Card class:

class Card {
  
/* constant suits and ranks */
static final String[] Suit = {“”,”Clubs”, “Diamonds”, “Hearts”,”Spades” };
static final String[] Rank ={“”,”A”,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”10″,”J”,”Q”,”K”};

/* Data field of a card: rank and suit */
private int cardRank; /* values: 1-13 (see Rank[] above) */
private int cardSuit; /* values: 1-4 (see Suit[] above) */

/* Constructor to create a card */
/* throw PlayingCardException if rank or suit is invalid */
public Card(int suit, int rank) throws PlayingCardException {
   if ((rank < 1) || (rank > 13))
       throw newPlayingCardException(“Invalid rank:”+rank);
   else
   cardRank = rank;
   if ((suit < 1) || (suit > 4))
       throw newPlayingCardException(“Invalid suit:”+suit);
   else
   cardSuit = suit;
}

/* Accessor and toString */
public int getRank() { return cardRank; }
public int getSuit() { return cardSuit; }
public String toString() { return Rank[cardRank] + ” ” +Suit[cardSuit]; }

Here is the Decks class:

public class Decks {

private List<Card> constructedDeck;   

private List<Card> gameDeck;

  
public Decks(int n) throws PlayingCardException
{
if (n<1) {
throw new PlayingCardException(“n < 1”);
}
  
constructedDeck = new ArrayList<Card>();
gameDeck = new ArrayList<Card>();
  
for (int i=1; i<=n; i=i+1) {
  
for (int suit=1; suit<=4; suit=suit+1) {
  
for (int rank=1; rank<=13; rank=rank+1) {
Card c = new Card(suit,rank);
constructedDeck.add(c);
}
}
}

gameDeck.addAll(constructedDeck);
}

public void shuffle()
{
Collections.shuffle(gameDeck);
}

public List<Card> deal(int numberCards) throwsPlayingCardException
{
if (numberCards>this.remainSize()) {
throw new PlayingCardException(“number of cards is greater thanremaining cards”);
}
  
List<Card> dealCards = new ArrayList<Card>();
  
for (int i=0; i<numberCards; i=i+1) {
  
Card c = gameDeck.remove(i);
  
dealCards.add(c);
}
  
return dealCards;
}

public void reset()
{ gameDeck.clear();
gameDeck.addAll(constructedDeck);

}

public int remainSize()
{
   return gameDeck.size();
}
  
public String toString()
{
   return “”+gameDeck;
}

import java.util.*; Ref: Short Description and Poker rules Video poker is also known as draw poker. The dealer uses a 52-card deck, which is played fresh after each playerHand. The player is dealt one five-card poker playerHand After the first draw, which is automatic, you may hold any of the cards and draw k again to replace the cards that you haven ‘t chosen to hold k Your cards are compared to a table of winning combinations k The object is to get the best possible combination so that you earn the highest k payout on the bet you placed. k Winning Combination:s 1. Jacks or Better: a pair pays out only if the cards in the pair are Jacks Queens, Kings, or Aces. Lower pairs do not pay out. k 2. Two Pair: two sets of pairs of the same card denomination. k 3. Three of a Kind: three cards of the same denomination. 4. Straight: five consecutive denomination cards of different suit k 5. Flush: five non-consecutive denomination cards of the same suit. 6. Full House: a set of three cards of the same denomination plus a set of two cards of the same denomination 7. Four of a kind: four cards of the same denomination 8. Straight Flush: five consecutive denomination cards of the same suit 9. Royal Flush: five consecutive denomination cards of the same suit, starting from 10 and ending with an ace /* This is the video poker game class It uses Decks and Card objects to implement video poker game Do not modify any data fields or defined methods You may add new data fields and methods Note: You must implement defined methods public class VideoPoker // default constant values private static final int defaultBalance 100; private static final int numberCards-5; // default constant payout value and playerHand types private static final int inningMultipliers-11,2,5,10,15,20,25,50,250; private static final String] winningHands-t “Royal Pair”, “Two Pairs” , “Three of a Kind”, “Straight”, “Flush “Full House”, “Four of a Kind”, “Straight Flush”, “Royal Flush” ; use one deck of cards private Decks thisDeck; // holding current player 5-card hand, balance, bet private List<Card> playerHand; private int playerBalance; private int playerBet; /*default constructor, set balance-defaultBalance public VideoPoker() this(defaultBalance); constructor, set given balance * public VideoPoker(int balance) this.playerBalance- balance; try t thisDeck – new Decks(1); catch (Exception e) t System.out.println (e.getMessage)); /This display the pavaut table based on winningMultipliers and winningHands arrays private void showPayoutTable() System.out.println(“nn”; System.out.println( “Payout Table System.out.println5455545″); int size – winningMultipliers.length for (int i-size-1; i -0; i–) t Multiplier”; System. out. println (winningHands [í]+”t It”+winningMultipliers [i)) ; System.out.println(“Inn”); /* Check current playerHand using winningMultipliers and winningHands arrays Must print yourHandType (default is “Sorry, you lost”) at the end of function This can be checked by testCheckHands() and main) method private void checkPlayerHand) // implement this method kokokokkkkkkkkkkk>k>k>kk***xxxxkkkkokok>kokokkk***x add new private methods here public void playGame /k The main algorithm for single player poker game Steps: showPayoutTable show balance, get bet verify bet value, update balance reset deck, shuffle deck, deal cards and display cards ask for positions of cards to keep get positions in one input line update cards check hands, display proper messages update balance if there is a payout if balance0: end of program else ask if the p layer Wants to play a new game if the answer is “no” end of program else showPayoutTable() if user wants to see it goto++ // implement this method Show transcribed image text import java.util.*; Ref: Short Description and Poker rules Video poker is also known as draw poker. The dealer uses a 52-card deck, which is played fresh after each playerHand. The player is dealt one five-card poker playerHand After the first draw, which is automatic, you may hold any of the cards and draw k again to replace the cards that you haven ‘t chosen to hold k Your cards are compared to a table of winning combinations k The object is to get the best possible combination so that you earn the highest k payout on the bet you placed. k Winning Combination:s 1. Jacks or Better: a pair pays out only if the cards in the pair are Jacks Queens, Kings, or Aces. Lower pairs do not pay out. k 2. Two Pair: two sets of pairs of the same card denomination. k 3. Three of a Kind: three cards of the same denomination. 4. Straight: five consecutive denomination cards of different suit k 5. Flush: five non-consecutive denomination cards of the same suit. 6. Full House: a set of three cards of the same denomination plus a set of two cards of the same denomination 7. Four of a kind: four cards of the same denomination 8. Straight Flush: five consecutive denomination cards of the same suit 9. Royal Flush: five consecutive denomination cards of the same suit, starting from 10 and ending with an ace /* This is the video poker game class It uses Decks and Card objects to implement video poker game Do not modify any data fields or defined methods You may add new data fields and methods Note: You must implement defined methods
public class VideoPoker // default constant values private static final int defaultBalance 100; private static final int numberCards-5; // default constant payout value and playerHand types private static final int inningMultipliers-11,2,5,10,15,20,25,50,250; private static final String] winningHands-t “Royal Pair”, “Two Pairs” , “Three of a Kind”, “Straight”, “Flush “Full House”, “Four of a Kind”, “Straight Flush”, “Royal Flush” ; use one deck of cards private Decks thisDeck; // holding current player 5-card hand, balance, bet private List playerHand; private int playerBalance; private int playerBet; /*default constructor, set balance-defaultBalance public VideoPoker() this(defaultBalance); constructor, set given balance * public VideoPoker(int balance) this.playerBalance- balance; try t thisDeck – new Decks(1); catch (Exception e) t System.out.println (e.getMessage));
/This display the pavaut table based on winningMultipliers and winningHands arrays private void showPayoutTable() System.out.println(“nn”; System.out.println( “Payout Table System.out.println5455545″); int size – winningMultipliers.length for (int i-size-1; i -0; i–) t Multiplier”; System. out. println (winningHands [í]+”t It”+winningMultipliers [i)) ; System.out.println(“Inn”);
/* Check current playerHand using winningMultipliers and winningHands arrays Must print yourHandType (default is “Sorry, you lost”) at the end of function This can be checked by testCheckHands() and main) method private void checkPlayerHand) // implement this method kokokokkkkkkkkkkk>k>k>kk***xxxxkkkkokok>kokokkk***x add new private methods here public void playGame /k The main algorithm for single player poker game Steps: showPayoutTable show balance, get bet verify bet value, update balance reset deck, shuffle deck, deal cards and display cards ask for positions of cards to keep get positions in one input line update cards check hands, display proper messages update balance if there is a payout if balance0: end of program else ask if the p layer Wants to play a new game if the answer is “no” end of program else showPayoutTable() if user wants to see it goto++ // implement this method

Expert Answer


Answer to Java. I need help implementing the checkPlayerHand() and playGame() methods in the VideoPoker class! Here is the Card cl… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *