Question
The deckOfCards project makes use of the Card class, the Deck class, the Hand class and the FiveCardStud class. Your job is to write the
The deckOfCards project makes use of the Card class, the Deck class, the Hand class and the FiveCardStud class.
Your job is to write the FiveCardStud class.
THE CARD CLASS, DECK CLASS AND THE HAND CLASS ARE ALREADY WRITTEN FOR YOU, DON'T CHANGE THEM.
Read the comments in the source code of the FiveCardStud class and finish writing the class according to those instructions.
Make sure your finished deckOfCards project is in your Homework6 folder on Lamont.
The example below shows the output from calling the FiveCardStud constructor with 4 players, calling the deal method, and then calling the showCards method.
-FIVE CARD STUD CODE:
import java.util.ArrayList;
/** * Deals out a game of 5-card-stud. * * @author PUT YOUR NAME HERE * @version PUT THE DATE HERE */ public class FiveCardStud { private Deck myDeck; private ArrayList
/** * Constructor for objects of class FiveCardStud */ /* Write a constructor for the FiveCardStud class. The constructor accepts a single integer parameter for the number of players. The number of players should be from 2 to 6 inclusive. Make sure to take care of values outside of this range. For numbers less than 2, set the number to 2 and print an appropriate message. For numbers greater than 6 set the number to 6 and print an appropriate message. For each player add a hand to the list of players. Print out the name of the game. Don't forget to initialize the fields. */
/** * Deal the cards. */ /* Write a method called "deal". The method should print out a message to let the user know that the cards have been dealt. It should remove any old cards from all players hands from previous games (Hint: there is a fold method in the Hand class.) It should then shuffle the deck and add 5 cards to each player's hand. */ /** * Prints out all player's hands. */ /* Write a method called "showCards". The method should print out each players hand as shown in the sample output. */ }
HAND CODE:
import java.util.ArrayList; import java.util.Iterator;
/** * Represents a single player's hand in a card game. * * @author Derek Green, Mar. 27, 04 * @revised by Allyson Anderson, Nov.1, 06 */ public class Hand { private ArrayList
/** * Constructor for objects of class Hand */ public Hand() { hand = new ArrayList
DECK CLASS CODE:
import java.util.ArrayList; import java.util.Iterator;
/** * Represents a deck of 52 playing cards. * * @author Derek Green, Mar. 26, 04 * @revised by Allyson Anderson, Nov. 1, 06 */ public class Deck { private final String[] suits = {"Spades ", "Hearts ", "Clubs ", "Diamonds"}; private final String[] faces = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
private Card[] card; private int topCard; /** * Construct a deck of cards */ public Deck() { card = new Card[52]; topCard = -1;//deal method will increment topCard for(int i = 0; i
for(int i = 0; i hand = new ArrayList
CARD CLASS CODE:
/** * Represents a single playing card. * * @author Derek Green, Mar. 26, 04 * @revised by Allyson Anderson, Nov. 1, 06 */ public class Card { private String suit; private String face;
/** * Constructor for objects of class Card. */ public Card(String suit, String face) { this.suit = suit; this.face = face; }
/** * Returns the suit of the card */ public String getSuit() { return suit; } /** * Returns the face of the card */ public String getFace() { return face; } /** * Returns the suit and face of the card as a single String */ public String getCard() { return face + "\t" + suit; } }
I'm pretty lost so any help would be apreciated thank you
Blue: Terminal Window Options Five Card Stud Poker ,, 1 minimum bet. Ante up and deal the cards! The cards have been dealt. PLAYER #1: Jack Hearts Spades Clubs Diamonds Spades PLAYER 2: Jack Clubs Diamonds Hearts Diamonds Diamonds PLAYER 3: 10 Queen Spades 10 Ace King Diamonds Hearts Spades Hearts PLAYER4: Jack Diamonds Hearts Clubs Spades 10 Jack SpadesStep 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