Question: Hello learning c++ here.. so far: #include #include using namespace std; class Card { friend class Deck; private: int face; string suit; public: Card(int face,

Hello learning c++ here.. so far:
#include
using namespace std;
class Card { friend class Deck; private: int face; string suit; public: Card(int face, string suit) : face(face), suit(suit) {} int getFace() { return face; } int getSuit() { return suit; } };
class Deck { private:
};
int main() {
}
I'm bit stuck on doing the array of suits like H, D, S, C and faces 2 - 10 in the class.
also, having trouble implementing the friend function. Not quite sure how I would use that.
I also need shuffle function and print function.
and try and catch for the exception part.
I'm not sure If I need vector.
Please help.
. . . Instructions: Create a program to shuffle and deal a deck of cards. The program should consist of class Card, class DeckOfCards, and a main program. Class Card should provide: Private data members face and suit of type int. A constructor that receives two ints representing the face and suit and uses them to initialize the data members. Two private static arrays of strings representing the faces and suits. (Face would be 2 through 10 and Jack, Queen, King, and Ace. Suit would be Diamonds, Hearts, Clubs, and Spades.) A listing of DeckOfCards as a friend of Card. Class DeckOfCards should contain: A private data member named deck that is an array of Cards. A private int data member named currentCard representing the index of the next Card to deal. A default constructor that initializes the Cards in the deck. A shuffle function that shuffles the Cards in the deck. The shuffle algorithm should iterate through the array of Cards. For each Card, randomly select another Card in the deck and swap the two Cards. A dealCard function that returns a string representation of the next Card object from the deck. The string should be in the form "face of suit". You can use the + operator to concatenate strings. This function throws an exception if the deck is empty. The main program should create a DeckOfCards object, shuffle the cards, then deal the cards until it catches the exception indicating that there are no more cards to deal. Do not write an infinite loop. Instead, exit gracefully using a Boolean flag
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
