Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THERE SHOULD BE TOTAL 7 FILES main.cpp, card.h, card.cpp, deck.h, deck.cpp, player.h, and player.cpp. Card.h, deck.h, and player.h is provide below. Project description: Write a

THERE SHOULD BE TOTAL 7 FILES main.cpp, card.h, card.cpp, deck.h, deck.cpp, player.h, and player.cpp.

Card.h, deck.h, and player.h is provide below.

Project description: Write a C++ program to simulate a simple card game between two players. The game should proceed as follows: The 52 cards in a deck of cards are shuffled and each player draws three cards from the top of the deck. The remaining cards are placed in a pile face-down between the two players. Players then select one of the three cards in hand and simultaneously place the chosen card face-up on the game table. The player who places the highest ranking card on the table collects both cards and adds them to their pile (score). If both cards have the same value the hand is a draw and no points are accumulated. Following the completion of a hand, each player draws the top card from the deck to add to their hand. Play continues until all cards have been played. The winner is the player with the most points at games end.

You will use a standard deck of 52 cards where there are thirteen cards from each of four suits: hearts, spades, diamonds, and clubs. The thirteen cards in point order are the 2-10 numbered cards, the face cards (Jack, Queen, King), and the Ace card. Points are distributed as follows: Ace=15, face cards=10, all other cards count as their numeric value.

Requirements:

1. program must be split into 7 files. There will be 3 classes (each with separate interface and implementation files), and a driver file. The requirements for these are specified below:

a) The Card class This class represents an individual card

Files must be named card.h and card.cpp

Class must be named Card

The interface (header file) is provided.

i. You should implement the interface file in a .cpp implementation file

ii. All data members must be of the type specified in the header file

iii. All member functions in the interface file must be implemented as declared However you have flexibility in how you choose to implement each

b) The Deck class This is represents the deck of cards

Files must be named deck.h and deck.cpp

Class must be named Deck

The interface (header file) is provided.

i. You should implement the interface file in a .cpp implementation file

ii. All data members must be of the type specified in the header file

iii. All member functions in the interface file must be implemented as declared However you have flexibility in how you choose to implement each

c) The Player class This class will represent the human and computer player Play is autonomous

Files must be named player.h and player.cpp

Class must be named Player

The interface (header file) is provided.

i. You should implement the interface file in a .cpp implementation file

ii. All data members must be of the type specified in the header file

iii. All member functions in the interface file must be implemented as declared However you have flexibility in how you choose to implement each

d) A driver, or client, file

Must be named proj4.cpp

Must contain the line srand(1000); as the first line of the main function

Must instantiate the card deck and the players, and control the gameplay, printing out the hand, scores, outcome (winner, loser, draw), and final winner and score as shown in the sample output.

Output for this program must clearly and neatly show that the program works and that it works correctly. Your output should:

1 . Display the entire deck of cards at the beginning of the game, and after it has been shuffled

2 . For each hand, show the cards and score of each player before the play, the card each player plays, and the cards and score of each player after the play (but before the next card is drawn)

3. At the end show the winner of the game and the winning score.

Below is a sample output of a games start and some late game hands as the game ends

2. Sample output:

a) Display of deck both before and after shuffling, and play of first couple of hands. Individual cards are output as card, suit, value. Example: 8 [8] is the 8 of spades which is worth 8 points; K [10] is the King of hearts with value 10. Note: depending on how you implement deck shuffling, the cards played may, or may not, match those below.

image text in transcribed

b.) Last few hands of the game. Note: The deck is exhausted after hand 23. Play continues until players are out of cards.

image text in transcribed

Note: You can use the following statements to print suit symbols: cout

image text in transcribed

image text in transcribed

image text in transcribed

he original deck has the foLIowing cards . [10] Q [ 101 J [ 101 10 [ 101 9[9] 8MB] 7 [7] The deck after shuffling top of deck listed first> Hand 1 layer layer 1's 2's hand: hand: 4[4] 6 [6] 6[6] with score 0 J. [10] 7[7] K. [10] with score 0 layer 1 played card : 6 [6] Player 2 played card: J10] layer 2 wins this hand layer 1's hand: 4 [41 6[6] layer 2's hand: with score 0 ?[7] K. [10] with score 16 Hand 2 layer 1's layer 2's hand: hand: 4 [4] 5[5] 6 [6] 5[5] with score 0 ? [7] K. [10] with score 16 )layer 1 played card: 6 [6] Player 2 played card: [?] layer 2 wins this hand layer 1's hand: 4 141 layer 2's hand: 5405.] 5 [5] with score 0 KVI101 with score 29

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions