It is time to show off all of your incredible talent and all that you have learned by programming a simple card game, we will use the concept of poker, but without actual cards. You will have three separate, or internal classes that will:
Instantiate a Card
Instantiate a Deck of those Cards, and shuffle and deal them.
Play the game.
In this project you will simulate the playing of a simple card game. You are given a Card and Deck class to use. The Card class should not be changed or renamed, I will use my own Card class when testing your files.
This assignment should be submitted in two classes; Main+lastName, Deck+lastName, or using internal declared classes, but will not be referenced in this manner henceforth. The first class, Deck, will be a modification of the class I have provided. You will need to implement the shuffleDeck method in order for this class to be usable, which has already been written for you in a method.
The second class, Main, will use the Card class and your modified Deck class to create a shuffled Deck object and deal the two hands. The hands should be dealt in alternating order, starting with the first hand. As the cards are dealt into each hand they should be removed from the deck.
For example, each hand is shown for the following Deck.
seven of spades <-- Index 0, top card
queen of spades <-- Index 1, etc.
ten of spades
eight of spades
three of spades
king of hearts
queen of hearts
jack of clubs
four of clubs
eight of clubs
king of diamonds
seven of hearts
Hand 1: Hand 2:seven of spades queen of spadesten of spades eight of spadesthree of spades king of heartsqueen of hearts jack of clubsfour of clubs eight of clubs
Each of these cards should be removed from the deck.
After dealing the hand, Main should use the point value attribute of each card to calculate the total point value of each hand. The hand with the highest point value wins. In the case of a draw, the second hand wins. In this game ace = 1, jack = 11, queen = 12, and king = 13. In the deck the card in the first position (index 0) is the top of the deck.
Lastly, Main will declare the winning hand. See the following sample run for the exact format that will be expected.
Sample Run of Main:
Hand 1: Total points 22
three of clubs (point value = 3)
two of clubs (point value = 2)
six of hearts (point value = 6)
ten of hearts (point value = 10)
ace of spades (point value = 1)
Hand 2: Total points 27
four of spades (point value = 4)
ten of clubs (point value = 10)
three of diamonds (point value = 3)
eight of diamonds (point value = 8)
two of hearts (point value = 2)
Hand 2 wins
Play again (y/n)?
To plan for the program, you should review the given classes. Knowing which methods are available to you will be very helpful in designing your game. Then, you should plan the algorithms that you will design.
Use the following table to plan your program.
Card/Deck Methods & VariablesMain
Card - Methods & Variables
String suit, String rank, int pointValue
public Card(String cardRank, String cardSuit, int cardPointValue)
public String suit()
public String rank()
public int getPointValue()
public boolean matches(Card otherCard)
public String toString(); use to print each card with a for each
Deck - Methods & Variables
private ArrayList
constructor method; instantiate deck ArrayList object, populate elements with cards by calling initialization method, and shuffle it by calling shuffleDeck() (written for you).
method to initialize the deck with 52 cards and set their point values; Ace of Clubs through King of Spades.
method to return the top card from the deck and remove it from the stack; return type should match what you are returning.
Main.main
instantiate a new Deck object based on Card element types
establish two arrays, one for each hand to be dealt
deal 5 cards to each hand calling the getTopCard() method from Deck{}
total up the values for each hand using getPointValue() from Card{}
display the cards and their point values for each hand
determine the winning hand and display
You do NOT need to hand in Card, nor customize the class or the instantiation usage of Card in Deck or Main! But you still need to change Deck and Main to include your last name.
PLAGIARISM will earn a ZERO! Copying someone else’s code online, or another student is also considered plagiarism.
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount