Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Java code for the following question: 6.) Dealing Cards Write a class named Card, which can be used to represent a card from a

Need Java code for the following question:

6.) Dealing Cards

Write a class named Card, which can be used to represent a card from a deck of cards. The class should be able to store a cards suit and face value. A cards suit can be one of the following: Hearts, Diamonds, Spades, or Clubs. A cards face value can be Ace, Jack, Queen, King, or a value in the range of two through ten.

Next write a Deck class. This class constructor should create a list of 52 Card objects, each representing a valid card in a deck of cards. The class should have a shuffle method that randomly shuffles the Card objects in the list. It should also have a deal method that deals a card from the deck. It does this by removing the Card object at the beginning of the list and returning a reference to that object.

Next, write CardPlayer class. This class should keep a list of Card objects that have been dealt to it. This represents a hand of cards. A method named getCard should accept a reference to a Card object, which is added to the list. A method named showCards displays the Card objects in the list.

Demonstrate these classes in an application that creates a Deck object, shuffles the cards it contains, and deals five cards from the Deck to a CardPlayer object. The CardPlayer should then display its cards

Ratings will be given to correct answers, Thank you

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

4. Support and enliven your speech with effective research

Answered: 1 week ago

Question

3. Choose an appropriate topic and develop it

Answered: 1 week ago