Question: Structured Data 2 C++ language Write a program that uses an array of struct s to represent a card deck, where the card values are

Structured Data 2 C++ language

Write a program that uses an array of structs to represent a card deck, where the card values are represented by enumerated types for the suit and rank. Your program will use functions to create the card deck, print a single card, print the card deck, deal two cards, then determine which card is the winner.

Requirements

  1. Use the enumerated types and data structures defined below:

enum suits {HEARTS, DIAMONDS, SPADES, CLUBS}; enum ranks {TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};

struct cards { suits suit; ranks rank; };

cards deck[52];

cards card1, card2;

  1. Create these functions according to the prototypes:

void createDeck(cards[]);

void printDeck(cards[]);

string cardName(cards); return a string containing the card name of the rank concatenated with the word "of" concatenated with the name of the suit.

cards deal(cards[]);

string winner(cards, cards);

  1. In main(), call the functions to:
    1. Create the deck
    2. Display the entire deck
    3. Randomly deal card 1
    4. Display card 1
    5. Randomly deal card 2
    6. Display card 2
    7. Display the winning card. (Ignore the suit for comparison. Ace is always high. If both ranks are the same, then display a tie.)
  2. Functions must pass parameters and return values as needed, using only local variables. Global variables are not allowed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!