Question: Hello learning c++ here. I'm very much stuck.. so the instruction asks for 'friend' function to use with the two classes.. having trouble with that.

 Hello learning c++ here. I'm very much stuck.. so the instruction

Hello learning c++ here. I'm very much stuck.. so the instruction asks for 'friend' function to use with the two classes..

having trouble with that. Also using two private members that take array of 13 faces and 4 suits to deal cards and shuffle.

so far I have written this.

#include #include

using namespace std;

class Card { friend DeckOfCards; private: int face; int suit; static string faces[13]; static string suits[4];

public: Card() {} Card(int face, int suit) : face(face), suit(suit) {} };

string Card::faces[] = { "Ace", "King", "Queen", "Jack", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" }; string Card::suits[] = { "Diamonds", "Hearts", "Clubs", "Spades" };

class DeckOfCards { private: Card deck[52]; int currentCard; public: DeckOfCards() {} void shuffle() {

} string dealCard() {

} };

int main() { DeckOfCards cards;

for (int i = 0; i

for (int i = 0; i

please help! Thank you.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!