Write a game of 5 card stud, where you play against the computer. The computer will be the dealer.

computer science

Description

Java

Write a game of 5 card stud, where you play against the computer. The computer will be the dealer.

Guide

5 Card Stud Final Project

Description of the Game

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

(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

Each player can bet, check (a bet of 0), or fold (give up this game)

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.

Object Design

Your client class will use five different objects, which you will have to create (listed above)

You will present a welcome message and a description to the user

Ask the user for their name and other information to create the Player object

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

Print a thanks for playing message

Your Card class

                value: Represents a point value of the card

                                Note: Aces can be a low or high card in poker

                suit: Represents one of the four card suits in a standard 52 card deck. This will                                   be done with an Enumeration.

                visible: A Boolean. Used to show or hide the first card dealt.

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)

show() and hide(): change the visible Boolean

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

compareTo(): compare cards to each other based on their value

Your Deck class

                cards: An ArrayList of Cards, with all 52 cards put in the list when the deck is created

shuffle(): A method to shuffle the ArrayList (use Collections.shuffle), call this as part of the                                         constructor

                deal(): A method to remove a Card from the deck and return it

Your Player class

                name: a String that holds the player’s name, or the word Dealer

                stash: an Int that holds the money the player can bet with. It must be a positive number

                hand: an ArrayList of cards that have been dealt to the player

                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)

                fold(): Give up this hand before the hand is done being dealt

scoreHand(): Return an Integer with a score based on the hand – use this for a guide                                                     http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/10/pokerCheck.html

See https://en.wikipedia.org/wiki/List_of_poker_hands

                toString(): Return a String showing the player’s name and the cards in their hand, along with                                      their stash of money

Your Dealer object

                Inherits from Player

                deck: A deck of cards

                dealToPlayer(Player player): A method to get a card from the deck and put it in the player’s                                        hand

Your Table object

                Pot: An Int that holds the bets from both players for each hand. Will initially be 0

                Players: A two element array of Player objects. One is the dealer, and the other is the player

                declareWinner(): A method to use each player’s scoreHand() results to pick a winner. See UML                                               diagram above and https://en.wikipedia.org/wiki/List_of_poker_hands

                show(): A method to show all cards face up on the table. Used after the last bet

                getBets(): A method to ask the player for a bet, and if valid, get the same bet from the dealer

                play(): A method to actually play the game – see pseudo code in description above


Related Questions in computer science category