Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Kartenspiel-CardGame Hello, can somebody help me with this task I would need a finished, running program to compare. Task: Write a program that

C++ Programming Kartenspiel-CardGame

Hello, can somebody help me with this task

I would need a finished, running program to compare.

Task:

Write a program that simulates the process of a card game in different variations. use

in addition the class CardGame and the supporting classes Player and Card (see class diagrams):

image text in transcribed

The following applies to the data elements and element functions:

The constructor of Card should suit and face with values for card color and card value taken from outside initialize and set the points depending on the card value. For

o the enumeration type Suit for the card color the values {KARO, HERZ, SPIK, KREUZ},

o the enumeration type face for the card value the values {SEVEN, EIGHT, NINE, TEN, BUBE, LADY, KING, ASS},

o for the point value (points) the whole numbers 0 (for card value SEVEN, EIGHT and NINE), 10 (with ZEHN), 2 (with BUBE), 3 (with DAME), 4 (with KOENIG) and 11 (with ASS) be used.

toString should return the values of suit, face and points in a suitable formatting as a string.

Each player has a unique identification number id, a certain number of cards in one vector and an integer sumOfPoints, which records how many points the player has for a given Time has. (The points result from the point values of the cards that the player played when playing receives; See description of play on the back.)

The player's constructor sets id to the value passed from outside as a parameter and initializes it sumOfPoints.

Player's member function push_back adds a card to the back of playerDeck, pop_back removes it last card from playerDeck and back returns the last card (without removing it).

4 players take part in the game, i.e. the constant class variable nrP has the value 4. A card game has 32 cards, i.e. deckSize has the value 32.

The CardGame constructor assigns unique identification numbers to the 4 players and generates this deck with the 32 different cards with their values of suit, face and points (see card constructor).

Note: You can use loops with suitable int values and the int values when passing them Cast to the card constructor in Suit or Face.

shuffle shuffles the deck of cards and deal distributes all cards from the deck in turn to the 4 players. After all Cards are distributed, the player decks of the individual players are sorted in ascending order as follows: All CROSS cards are higher than all PIK cards, these are higher than all HEART cards and these are higher than all KARO cards. Within the individual colors, the sequence ACE, KOENIG, DAME, BUBE, TEN, NINE, EIGHT and applies SEVEN (ACE highest and SEVEN lowest).

play realizes a game: in each round each player has to play his highest card. The point values (points) of the 4 played cards in each round are added and the player receives the total the highest of the 4 played cards in its sumOfPoints by calling the element function addPoints credited. In addition, the cards played in this round of all players are taken from the respective playerDecks removed. Then the next round follows.

After completing all game rounds, the players within players should descend according to their sumOfPoints be sorted. play should have two different ways of working: Either the sumOfPoints of the players are each only calculated for one game (i.e. recalculated each time play is called up) or in the players' sumOfPoints the results for a number of games are added up. The way play can be specified externally via a Boolean parameter (see requirements for main).

showPlayers gives the distribution of the cards to the 4 players at a given time in an appropriate Formatting as a string.

showResult gives

first the identification number of the winner of the game,

Then for all 4 players the identification number and the number of points achieved

and finally, as a control, the sum of the scores of all 4 players in a suitable formatting as a string.

The application program (main) should carry out the simulations. The following actions are to be taken in sequence run (so no menu should be implemented):

Creation of a CardGame object and calling deal and showPlayers (without mixing!).

Creation of another CardGame object and calling shuffle, deal and showPlayers. Then play a game with this object by calling play and calling showResult.

Generation of another CardGame object and execution of ten complete games (shuffling, dealing, Play out and display the result of each individual game) with this object.

Generation of another CardGame object and execution of 1000 games (shuffling, dealing, playing out and show the total result of all 1000 games) with this object. Doing this should include the points that everyone Players in each of the 1000 games achieved are added up and so the total scores they have in all Games are spent (sorted in descending order according to the total number of points).

CardGame Card + nrP: int + deckSize: int players: array deck: array + CardGame () + shuffle () : void + deal(): void + play (bool): void + showPlayers (): string + showResult(): string Player id: int sumofPoints: int playerDeck: vector + Player (int) + clearPlayerDeck(): void + push_back (Card): void + pop_back(): void + back(): Card + size(): int + clearSumofPoints(): void + addPoints (int) : void + tostring(): string + suit: Suit face: Face points: int + Card (Suit, Face) + toString(): string +

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

2. Initialize (the values in ).

Answered: 1 week ago

Question

Q: Is your system characteristic of the Israeli workplace?

Answered: 1 week ago