Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ONLY 50 points Create a standard deck of 52 playing cards and list those cards on the screen, columns makes my life easier :-)

C++ ONLY

50 points

Create a standard deck of 52 playing cards and list those cards on the screen, columns makes my life easier :-) Pause or "press Enter" after the unshuffled deck is displayed. The display might look something like.

"Shuffle" the deck and list the shuffled deck on the screen. random_shuffle from will work on a vector of Cards

Sort (by rank) and evaluate evaluate the first 5 cards of the deck as a 'hand'. Print the unsorted, then the sorted hand.

a pair (say the card rank, like Pair of Queens)

two pair (say something like Pair of Queens and Pair of Twos)

three of a kind (say something like Three Kings)

full house (say something like Full house, Jacks over fours)

straight (say Ace-high straight) A straight is all 5 cards in rank order, ace can be high or low

four of a kind

flush (say something like spades flush)

Ideas:

create a Card class with an internal 'Rank' (A, 2, 3, 4, ..) and 'Suit' (spades, diamonds ...)

Here's one possible idea for a card class (Card.h)

#ifndef CARD_H

#define CARD_H #include using namespace std; class Card { public: Card(); // set and get the rank, 2=2, 3=3, ... 10=10, 11=J, 12=Q, 13=K, 14=A void setRank(int r); int getRank(); // set and get the suit, 1=Spades, 2=Hearts, ... void setSuit(int r); int getSuit(); // for debugging, print the suit and rand as integers void print(); // return the rank and suit as a 'nice' looking string string toString(); // if you want to use sort() in the STL bool operator<(const Card &c) const {return myRank < c.myRank;} private: int myRank; int mySuit; }; #endif // CARD_H

If you want to use the builtin sort alogrithm with the above class, use:

vector hand; /// make sure to put cards in the hand here! sort(hand.begin(), hand.end());

For those who like icons, check out the following:

int main() { cout << "\003" << endl; cout << "\004" << endl; cout << "\005" << endl; cout << "\006" << endl; return 0; }

Please use C++!!!

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

How To Make Money In Crypto The Beginners Guide To Bitcoin

Authors: Joyce E Thompson

1st Edition

180438075X, 978-1804380758

Students also viewed these Databases questions

Question

=+. I wish he would get off of the phone.

Answered: 1 week ago