Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++: 1. Specify, design, and implement a class for a card in a deck of playing cards. The object should contain methds for setting

In C++:

1. Specify, design, and implement a class for a card in a deck of playing cards. The object should contain methds for setting and retrieving the suit and rank of a card.

2. Use the card class developed to create a new class for a deck of cards. The deck class has a sequence with a capacity of 52 to hold the cards. The constructor assigns 52 cards in order of suit and rank to the sequence. A friend function should display the entire deck using words (i.e., "the ace of spades").

3. Modify the card and deck classes so that they will be useful in a program to shuffle a deck of cards, deal all the cards to four plaers, and display each player's hand. For the shuffle function, generate a random number k for each card index whose value is from 0 to index. Then define a swap function to exchange the values for card[index] and card[k], using a swap function that you define.

4. Use a cirucular linked list to run a simple simulation of a card game. Use the card and deck classes, and shuffle and deal already created. Create a player class to hold a hand of dealt cards. During each turn, a playerwill discard a card. Use rand() to determine who gets the first turn in each hand, and make sure each person has a turn during every hand. The program ends when all cards have been played.

The program should also include the following in the program:

Construct an object oriented approach that implements classes with private data, public constructors (default, parameter, and copy), public accessor and mutator methods for private data, friend functions and overloaded operators as appropriate. Only const accessor methods may be declared inline. Class methods should use passed parameters only when they are not already stored as private data members in the object.

Card class declares and uses enumerated types for suit (clubs, diamonds, hearts, spades) and card rank (two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace)

Card class overloads << operator to display suit and rank as a descriptive string as well as the cards value. There should be an integer value identified for each card rank. Include your assumption to define integer values for jack, queen, king and ace.

Card class overloads the + operator to return the combined integer value of any combination of a Card object and integer. Adding two or more cards, card and integer, or integer and card, will return the combined integer value of all the operands. For example, the two of clubs and four of diamonds would have a combined value of 6.

Deck class member function to shuffle cards in the deck using algorithm described in textbook.

Include a name with the Player class to identify each player. Use a linked list to hold the cards for each player. Include a public member function to return the combined value of all cards in their hand (use overloaded Card class + operator).

After cards are dealt to four players at the beginning of the game card simulation, display each players name, the cards in their hand (using Card class overloaded << operator) as well as the combined value of all cards in the hand.

please pay attention to all the requirements.

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_2

Step: 3

blur-text-image_3

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

Students also viewed these Databases questions