1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Deck newShuffledDeck(void) {
srand(clock());
std::string vals[] = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
std::string vers[] = {"Clubs", "Spades", "Hearts", "Diamonds"};
std::vector<std::string> values;
std::vector<std::string> versions;
values.assign(vals, vals+13);
versions.assign(vers, vers+4);
Deck d;
for (int i = 0; i < 4; i++) {
for(int j = 0; j < 13; j++) {
int vSel = rand()%values.size(); //this is problematic!!
Card c(values[vSel], versions[i]);
values.erase(values.begin()+vSel);
d.push_back(c);
}
}
return d;
}
|