Question: The following program simulates shuffling of cards. While it does the job, it is not very object-oriented. There are no Card objects! Fix that by

The following program simulates shuffling of cards. While it does the job, it is not very object-oriented. There are no Card objects! Fix that by defining a Card class and using a vector of Card objects instead of vector.

Complete the following file: (Use the code below) (Will post images as reference and code to copy and paste into compiler) (Areas in the code that are grey cannot be changed, only the white areas) Thank you!

The following program simulates shuffling of cards. While it does the job,it is not very object-oriented. There are no Card objects! Fix thatDown below is the same code as the images if you need to copy and paste onto compiler.

Cards.cpp

#include #include #include

using namespace std;

// Define a class Card

class Card { public: Card(string v, string s); // ... private: // ... }; // ...

int main() { srand(42); // Change this code to use a vector of Card objects

vector values; vector suits;

// Change this code to add Card objects to the vector

values.push_back("Ace"); suits.push_back("Spades"); values.push_back("9"); suits.push_back("Hearts"); values.push_back("Queen"); suits.push_back("Diamonds"); values.push_back("6"); suits.push_back("Clubs");

const int CARDS = 4; const int SHUFFLES = 10; for (int i = 0; i

string temp = values[from]; values[from] = values[to]; values[to] = temp;

temp = suits[from]; suits[from] = suits[to]; suits[to] = temp;

}

for (int i = 0; i

cout

}

return 0; }

Complete the following file: Cards.cpp #include #include #include using namespace std; // Define a class Card class Card { public: Card(string v, string s); private: }; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 int main() { srand(42); // Change this code to use a vector of Card objects vector values; vector suits; // Change this code to add Card objects to the vector values.push_back("Ace"); suits.push_back ("Spades"); values.push_back("9"); suits.push_back("Hearts"); values.push_back("Queen"); suits.push_back("Diamonds"); values.push_back("6"); suits.push_back("Clubs"); const int CARDS = 4; const int SHUFFLES = 10; for (int i = 0; i

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!