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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Card
{
int face, suit;
static char *faces[];
static char *suits[];
public:
Card(int, int);
char* toString(int a,int b)
{
//cout << getFaces(getFaceCard()) << " of " << getSuits(getCardSuit()) << "\n\n"; //For Test Purposes
char *FKard = getFaces(getFaceCard());
char *SKard = getSuits(getCardSuit());
int n;
static char buffer[14];
n = sprintf(buffer,"%s of %s", FKard,SKard);
//printf("%s <-------\n",buffer); //for test purposes
//cout << buffer << endl; //test purposes
return (buffer);
};
int getFaceCard()
{
return face;
}
int getCardSuit()
{
return suit;
}
static char*getFaces(int a)
{
char*CFaces = new char[15];
CFaces = (faces[a]);
return CFaces;
}
static char*getSuits(int b)
{
char*CSuits = new char[5];
CSuits = (suits[b]);
return CSuits;
}
friend class DeckOfCards;
};
class DeckOfCards
{
vector<char> Deck;
int currentCard;
public:
DeckOfCards(char buffer) //------problem function
{
Deck.push_back(buffer);
shuffle();
for (vector<char>::iterator i = Deck.begin(); i != Deck.end(); i++)
{
cout << *i <<endl;
}
}
void shuffle()
{
random_shuffle(Deck.begin(),Deck.end());
}
char dealCard()
{
}
bool moreCards()
{
}
};
char *Card::faces[] = { "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
char *Card::suits[] = { "Clubs", "Hearts", "Diamonds", "Spades" };
Card::Card(int a, int b)
{
face = a;
suit = b;
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i < 13; i++)
{
for (int j = 0; j < 4; j++)
{
Card kard(i,j);
char *moo = (kard.toString(kard.getFaceCard(),kard.getCardSuit()));
//cout << moo << endl; // for test purposes
DeckOfCards DoC(moo[i]); //<-------problem is here
}
}
cout <<endl<< "^^^^^^^^^^^^^^^^^^"<< endl;
cout << " "<< endl;
system("pause");
return 0;
}
|