Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I t i s time t o show off all o f your incredible talent and all that you have learned b y programming a

Itis 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. 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 tobe usable, which has already been written for you in a method at the bottom.
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 spades
ten of spades eight of spades
three of spades king of hearts
queen of hearts jack of clubs
four 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 (index0)is the top of the deck.
Lastly, Main will declare the winning hand, and then ask the player if they want to play again. 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 (yn)?
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.
CardDeck Methods & Variables Main
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 deck;
constructor method; instantiate deck ArrayList object, populate elements with cards by calling initialization method, and shuffle itby 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 tobe 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

Students also viewed these Databases questions