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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
#include <cstdlib>
#include <iostream>
#include <strings.h>
#include <vector>
using namespace std;
using std::string;
using std::endl;
using std::vector;
//classes
class CPU
{
public:
string sName;
int nDiff;
int Getdifficulty(void);
string Getname(void);
};
class player
{
public:
string sName;
string Getname();
};
class card
{
public:
int nSuit;//0 = clubs 1 = hearts 2 = diamonds 3 = spades
int nVal;//0=A 1=2 etc... 12 =K
};
class deck
{
public:
vector<card> deckofcards;
string Getcardvalue(int j);
string Getcardsuit(int f);
bool batman;
void Setdeck(void);
void Showcards(void);
void Dealcards(void);
};
class hand
{
public:
int Sizeofhand;
vector<card> han();
};
/* END CLASSES
variable deffinition
*/
player p;
deck d;
CPU k;
void Giveinfo(CPU k, player p);
void Setup(player p, CPU k, deck d);
int main(int argc, char *argv[])
{
Setup(p,k,d);
d.Showcards();
system("PAUSE");
return EXIT_SUCCESS;
};
/*
FUNCTIONS ARE BELOW
*/
string player::Getname(){
string r;
cout << "Please type your name (with no spaces)" << endl;
cin >> r;
return r;
};
string CPU::Getname(){
string r;
cout << "Please type the name of your CPU opponent (no spaces)" << endl;
cin >> r;
return r;
};
int CPU::Getdifficulty(void)
{
int d;
bool iscorrect;
while (iscorrect != true)
{
cout << "Please type 1, 2, or 3 for the level \n of difficulty you would like." << endl;
cin >> d;
iscorrect=true;
if (d>3) {
cout << "That's more than 3, lets try this again..." << endl;
iscorrect=false;
}
else if (d<1) {
cout << "That's less than 1, lets try this again..." << endl;
iscorrect=false;
};
};
return d;
};
void Giveinfo(CPU k, player p)
{
cout << "Your name is " << p.sName << "." << endl;
cout << "Your opponent is a CPU with a level of " << k.nDiff << "." << endl;
cout << "His name is " << k.sName << "." << endl;
return;
};
void deck::Setdeck(void){
int f;
//DECLARE DECKOFCARDS SIZE HERE NOW NOW NOW
deckofcards.resize(52);
for(f=0; f <52; f++){
deckofcards[f].nSuit = f%4;
deckofcards[f].nVal = f%13;
};
batman=true;
};
void deck::Showcards(void){
if (batman=true){
for (int g=0; g<52; g++){
cout << Getcardvalue(deckofcards.at(g).nVal) << " of " << Getcardsuit(deckofcards.at(g).nSuit) << endl;
};
};
};
string deck::Getcardvalue(int j){
j=j%13;
switch (j){
case 0:
return "Ace";
break;
case 1:
return "Two";
break;
case 2:
return "Three";
break;
case 3:
return "Four";
break;
case 4:
return "Five";
break;
case 5:
return "Six";
break;
case 6:
return "Seven";
break;
case 7:
return "Eight";
break;
case 8:
return "Nine";
break;
case 9:
return "Ten";
break;
case 10:
return "Jack";
break;
case 11:
return "Queen";
break;
case 12:
return "King";
break;
};
};
string deck::Getcardsuit(int f){
f=f%4;
switch (f){
case 0:
return "Clubs";
break;
case 1:
return "Hearts";
break;
case 2:
return "Diamonds";
break;
case 3:
return "Spades";
break;
};
};
void Setup(player p,CPU k, deck d){
p.sName=p.Getname();
k.sName=k.Getname();
k.nDiff=k.Getdifficulty();
Giveinfo(k,p);
d.batman = false;
d.Setdeck();
};
void deck::Dealcards(void){
};
|