Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey, I'm working on a project for my class for making a basic card game that deals two cards and chooses the highest here are

Hey, I'm working on a project for my class for making a basic card game that deals two cards and chooses the highest here are the instructions:

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 cardValue. 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 {CLUBS, DIAMONDS, HEARTS, SPADES};

enum cardValues {TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};

struct cards {suits suit; cardValues card; };

cards deck[52]; cards card1, card2;

2. Define and implement the following functions:

void createDeck (cards[]);

void printDeck (cards[]);

void printCard(cards);

void deal (cards[], cards&);

void winner (cards, cards);

3. Write a main program that calls the functions to:

a. Create the deck

b. Print the deck

c. Randomly deal card 1 (Hint: use the random function (see page 128) to randomly generate a number between 0 and 51 that represents the array location of the card).

d. Print card 1

e. Randomly deal card 2

f. Print card 2

g. Print the winning card

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions