Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started