Question
USING JAVA The computer will always be the dealer, and will always match all bets by the player. The dealer will start out with 5
USING JAVA The computer will always be the dealer, and will always match all bets by the player. The dealer will start out with 5 times as much money as the player o (Remember, the house always wins, so they can afford it) The player will put money on the table to enter the game (an initial bet), called the ante. Both players are dealt 1 card face down, then one card face up. Loop until each player has 5 cards each round gives both players 1 card o Each player can bet, check (a bet of 0), or fold (give up this game) o Once all bets have been made, another card is dealt face up to all players Once all players have 5 cards, a final bet is made, or the player can fold All players show all cards The player with the best hand wins the pot The dealer collects all cards and shuffles the deck, and another hand is played until the player chooses to quit or one of the two players is out of money. If a player folds, the dealer wins the pot automatically. For simplicity, our dealer (the computer) will never fold, and will match all bets from the player. Your client class will use five different objects, which you will have to create (listed above) o You will present a welcome message and a description to the user o Ask the user for their name and other information to create the Player object o Start the loop to control the game ? Create a dealer (this will make a new deck of cards for each hand) ? Create a table ? Add the player and the dealer to the table ? Call table.play() ? Ask if the player wants to play again, or quit if they are out of money o Print a thanks for playing message
Your Card class
o value: Represents a point value of the card ? Note: Aces can be a low or high card in poker
o suit: Represents one of the four card suits in a standard 52 card deck. This will be done with an Enumeration.
o visible: A Boolean. Used to show or hide the first card dealt.
o name: A String, and will be either the number of the card (i.e. 3 or 10), or the actual name if it is a face card (i.e. Queen or Ace)
o show() and hide(): change the visible Boolean
o toString(): Represent the card. It should output the name and suit of the card, like this: 3 of Spades, or Queen of Hearts, or Hidden Card if visible == false
o compareTo(): compare cards to each other based on their value
Your Deck class
o cards: An ArrayList of Cards, with all 52 cards put in the list when the deck is created
o shuffle(): A method to shuffle the ArrayList (use Collections.shuffle), call this as part of the constructor
o deal(): A method to remove a Card from the deck and return it
Your Player class
o name: a String that holds the players name, or the word Dealer
o stash: an Int that holds the money the player can bet with. It must be a positive number
o hand: an ArrayList of cards that have been dealt to the player
o bet(): Get the bet for this round from the player. Return the Int of the bet, or -1 if the bet is invalid (they bet more than they have, or bet a number)
o fold(): Give up this hand before the hand is done being dealt
o scoreHand(): Return an Integer with a score based on the hand .
o toString(): Return a String showing the players name and the cards in their hand, along with their stash of money
Your Dealer object o Inherits from Player
o deck: A deck of cards
o dealToPlayer(Player player): A method to get a card from the deck and put it in the players hand
Your Table object
o Pot: An Int that holds the bets from both players for each hand. Will initially be 0
o Players: A two element array of Player objects. One is the dealer, and the other is the player
o declareWinner(): A method to use each players scoreHand() results to pick a winner.
o show(): A method to show all cards face up on the table. Used after the last bet
o getBets(): A method to ask the player for a bet, and if valid, get the same bet from the dealer
o play(): A method to actually play the game
As you develop each class, be sure to write a unit test suite that will be used to test each method and branch of code. Combine all unit tests into a TestDriver class that can be used to show unit testing for each class. A menu shall be provided allowing the tester to select the class to run under test. Exit this menu through selection.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started