Create a game of video poker with a graphical user interface (GUI). The player s
ID: 3820037 • Letter: C
Question
Create a game of video poker with a graphical user interface (GUI). The player should start with $100, and then the system deals out 5 playing cards. After the player sees the cards they are then asked to wager $10, $20, $50, or $100. Next the user picks which cards they wish to throw away, and then the system deals more cards in their place. Once this has concluded money are awarded by these criteria: Nothing - Player loses their wager Pair - Player gets back their wager Two Pair - Player wins wager times 2 3 of a kind - Payer wins wager times 3 Full House - Player wins wager times 6 Flush - Player wins wager times 10 Straight - Player wins wager times 15 4 of a kind - Player wins wager times 20 Royal Flush - Player wins wager times 100 If the player's cash is less than or equal to 0 the game is over, and they restart with $100. Also once they close the program it should store the score in a file that once they restart it they begin with the score they once had.Explanation / Answer
/** * PokerHand.java * This is code for a class that represents a Poker Hand. It is * useful for a draw poker game in which the hand is made up of * 5 cards. The ranks are as follows: 9 - Royal Flush; 8 - Straight * Flush; 7 - Four of a Kind; 6 - Full House; 5 - Flush; 4 - Straight; * 3 - Three of a Kind; 2 - Two Pair; 1 - Pair; 0 - Bust (nothing) */ public class PokerHand { private Card [] hand; private int rank; /** * PokerHand(Card c1, Card c2, Card c3, Card c4, Card c5) * Input: 5 Card objects that will make up the poker hand * Output: none * Description: Creates a PokerHand object with the 5 cards * passed in as parameters. It uses the evalRank() method * to give assign a rank to the hand. */ public PokerHand(Card c1, Card c2, Card c3, Card c4, Card c5) { hand = new Card[5]; hand[0] = c1; hand[1] = c2; hand[2] = c3; hand[3] = c4; hand[4] = c5; evalRank(); }//end Constructor /** * PokerHand() * Input: none * Output: none * Description: Creates a random poker hand through a call to the * other poker hand constructor and the random Card constructor. */ public PokerHand() { this(new Card(), new Card(), new Card(), new Card(), new Card()); }//end Constructor /** * getRank() * Input: none * Output: an integer representing the rank of the card */ public int getRank() { return rank; }//end getRank /** * hasAce() * Input: none * Ouptut: boolean - true if hand has an ace, false otherwise * Description: A simple utility method used to determine whether * the hand has an ace or not */ public boolean hasAce() { for(int i = 0; i < 5; i++) if(hand[i].getRank() == 14) return true; return false; }//end hasAce /** * gameToString() * Input: none * Output: a String representation of the hand * Description: A method that is useful in the DrawPoker * game - prints out the hand numbered without printing * out the rank (the user should figure that out!) */ public String gameToString() { String result = new String(""); for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.