Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will consist of three files: 1. card.h : card class 2. stack.h : stack class 3. main.cpp : main program card class Create

This program will consist of three files:

1. card.h: card class

2. stack.h: stack class

3. main.cpp: main program

card class

Create the following class representing a playing card:

class card

{

private:

char suit; // h, d, c, s

int rank; // 1: ace, 11: jack, 12: queen, 13: king

public:

// sets suit and rank to the given values

void create (char s, int r);

// prints a card in the form: Ace of

void print ();

};

stack class

Make the following changes to the stack class written in class:

1. Include the card class in the stack.h file

2. Change the data type in the class to be an array of card type instead of char type. This requires changes in a number of places in the file.

3. Add a function called print that prints the elements in the stack, each card on a separate line, from the top element to the bottom element. You will use the print function in the card class to print the individual cards. print should not change the stack.

main program

The main program should make a standard deck of 52 cards (this will be a stack), print the deck, sort the deck, and print the deck again. You are required to write the following functions:

// puts the standard 52 cards into the stack of

// cards. The order of the cards is not important

// as long as all 52 are there.

void make_deck (stack& deck);

//

// mixes the cards in the deck using the following

// algorithm:

// declare two stacks temp1 and temp2

// repeat 100 times

// {

// for each card in the deck

// {

// remove a card from the deck

// randomly place that card on temp1 or temp2

// }

// move all the cards from temp1 back to deck

// move all the cards from temp2 back to deck

// }

//

void mix_deck (stack& deck);

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

More Books

Students also viewed these Databases questions

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago