Card Game problem

Hi, everyone,
i am new to c++. I have been trying to write this code for a while. I am really stuck in converting my code into object oriented with structs. The card game is called My boat sails where i have to create Card struct, Player with card vector and Game with vector of cards and vector of players. I did this so far.

#include <string>
#include <iostream>
#include <deque>
#include <vector>
#include <random>
#include <algorithm>
#include <ctime>

using namespace std;

const string suit[] = {"D", "H", "S", "C"};
const string facevalue[] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};

deque<string> the_deck =[] {
deque<string> result;
for (int i = 0 ; i < 52 ; ++i) {
result.push_back(facevalue[i % 13] + suit[i % 4]);
}
auto eng = default_random_engine(random_device()());
srand(time(0));
shuffle(begin(result), end(result), eng);
return result;
}();

string getCard () {
auto result = the_deck.front();
the_deck.pop_front();
return result;
}

void print_hand(vector<string>& hand) {
char choice = 'a';
auto sep = "";
for(auto& card : hand) {
cout << sep << "(" << choice << ")" << card;
sep = " ";
++choice;
}
}

using hand_type = vector<string>;
using player_hands_type = vector<hand_type>;

int main () {
const int DEAL_CARDS = 7; //number of cards we can deal to each player
const int PLAYERS = 5; //number of cards we can deal to each player
player_hands_type hands;
srand(time(0));
for (int player = 0 ; player < PLAYERS ; ++player) {
hand_type hand;
generate_n(back_inserter(hand), DEAL_CARDS, getCard);
hands.push_back(move(hand));
}
print_hand(hands[0]);
cout << "\n\nWhich one to replace? ";


return 0;
}

Topic archived. No new replies allowed.