Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ ONLY 50 points Create a standard deck of 52 playing cards and list those car

ID: 3865629 • Letter: C

Question

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 <algorithm> 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 <string>

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<Card> 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 << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
return 0;
}

Please use C++!!!

Explanation / Answer

************card.cpp*****

****************

********************************

*******************

********************

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote