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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
std::vector<std::string> suits { "C", "D", "H", "S" };
here { has a red squiggle that says " expected a ;"
and
unshuffled.push_back (std :: to_string(val) + suits[s]);
where std says " more than one instance of overloaded function " std :: to_string" matches the arguments list.
Although shuffleCards() is a function my professor gave me so I would think that was the problem.
This is what I have.
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
//////////////////////////////////////////////
// Functionality I have provided for you //
//////////////////////////////////////////////
std::vector<std::string> _cards;
void displayMenu();
void shuffleCards();
void printCards();
int getCardValue(std::string card);
std::string getSuit(std::string card);
std::string drawCard();
///////////////////////////////////////////END
////////////////////////////////////////////
//////////////////////////////////////////////
// Functionality you need to provide //
//////////////////////////////////////////////
// basic casino functionality
void seedRand(int seed);
void printMoney(double money);
void printWallet(double wallet);
void payMoney(double & wallet, double amount);
void winMoney(double & wallet, double amount);
int getRandomNumber(int min, int max);
double placeBet(double & wallet);
// games
void playFlipTheCoin(double & wallet);
void playGuessTheNumber(double & wallet);
void playStreetCraps(double & wallet);
void playBlackjack(double & wallet);
///////////////////////////////////////////END
//////////////////////////////////////////////
void seedRand()
{
srand(time(0));
}
void printMoney (double money)
{
cout << "$" << setprecision(2) << fixed;
}
void printWallet (double wallet)
{
cout << "Wallet: "<< " " << printMoney;
}
void payMoney (double & wallet, double money)
{
cout << wallet;
wallet -= money;
cout << " You Paid " << " " << money << "\n";
cout << wallet;
}
void winMoney ( double & wallet, double money)
{
cout << wallet;
wallet += money;
cout << "You just won" << " " << money << "\n";
cout << wallet;
}
int getRandomNumber(int min, int max)
{
int r = getRandomNumber(min, max);
std::cout << r << "\n";
return r;
}
double placeBet(double & wallet)
{
cout << " How much do you want to bet" << "\n";
cin >> wallet >> "\n";
- wallet;
double bet = placeBet(wallet);
cout << payMoney << "\n";
cout << "Your original bet was " << " " << bet;
}
int main()
{
// You need money to spend on the games
double wallet = 20.00;
// Here is where you should begin writing your code.
// The first thing you need to do is call seedRand.
// After that, create your loop. Inside of your loop,
// call my displayMenu function and act on the user's
// input.
// Write some code here
seedRand();
displayMenu();
char gameSelection;
cin >> gameSelection;
switch (gameSelection)
{
case 'F':
case 'f':
playFlipTheCoin(wallet);
case 'G':
case 'g':
playGuessTheNumber(wallet);
case 'S':
case 's':
playStreetCraps(wallet);
case 'B':
case 'b':
playBlackjack(wallet);
break;
case 'X':
case 'x':
break;
default:
cout << " Invalid Selection! \n";
displayMenu();
break;
}
// Here's courtesy code to stop the window from closing.
std::cout << "Press ENTER to continue";
std::cin.ignore();
std::cin.get();
}
void playFlipTheCoin (double & wallet)
{
cout << " Welcome to the flip a coin game!" << "\n";
payMoney (wallet, .50);
cout << " Guess (H)eads or (T)ails!" << " ";
char coinguess;
cin >> coinguess;
cout << "\n";
int RanNum = getRandomNumber (1,2);
int coinface;
int head;
int tails;
if (RanNum == 1)
coinface == head;
if (RanNum == 2)
coinface == tails;
switch (coinguess)
{
case 'H':
case 'h':
{if (coinface == head)
{cout << "The coin landed on heads";
cout << " \n You guessed heads thats right!";
winMoney(wallet, 1.00);
cout << " \n You just won a $1.00";}
if (coinface == tails)
{cout << "The coin landed on Tails";
cout << " \n You guessed heads you're wrong....haha";} }
case 'T':
case 't':
if (coinface == tails)
{cout << "The coin landed on tails";
cout << " \n You guessed tails thats right!";
winMoney(wallet, 1.00);
cout << " \n You just won a $1.00";}
if (coinface == head)
{cout << "The coin landed on Heads";
cout << " \n You guessed tails you're wrong....haha"; }
}
}
void playGuessTheNumber (double & wallet)
{
while(true) { // Main loop.
// Initialize and allocate.
int number = getRandomNumber(1,100);
int guess; // User guess is stored in here.
int tries = 0; // Number of tries is stored here.
char answer;
cout << "Welcome to the Guess a number game";
payMoney (wallet, 1.00);
while(true) { // Get user number loop.
// Get number.
std::cout << "I have may sercet number. \n Enter a number between 1 and 100 (" << 10 - tries << " tries left): ";
std::cin >> guess;
std::cin.ignore();
// Check is tries are taken up.
if(tries >= 10) {
break;
}
// Check number.
if(guess > number) {
std::cout << "Too high! Try again.\n";
} else if(guess < number) {
std::cout << "Too low! Try again.\n";
} else {
break;
}
// If not number, increment tries.
tries++;
}
// Check for tries.
if(tries >= 10) {
std::cout << "You ran out of tries!\n\n";
} else {
// Or, user won.
std::cout<<"Congratulations!! " << std::endl;
std::cout<<"You just won $2.00 \n";
winMoney(wallet,2.00);
}
}
}
void playStreetCraps (double & wallet)
{
int diceroll();
cout << "Welcome to street craps";
printWallet ( wallet);
placeBet ( wallet );
int diceroll();
{
int die1 = getRandomNumber (1,6);
int die2 = getRandomNumber (1,6);
int sum = die1+ die2;
cout << " You rolled " << die1 << "+" << die2 << "=" << sum << endl;
}
enum status { CONTINUE , WON , LOST};
int point;
status gameStatus;
int dicesum = diceroll();
switch (dicesum)
{
case 7:
case 11:
gameStatus = WON;
break;
case 2:
case 3:
case 12:
gameStatus = LOST;
break;
default:
gameStatus = CONTINUE;
point = dicesum;
cout << " Point is" << point << endl;
break;
}
while (gameStatus = CONTINUE)
{
dicesum = diceroll();
if(dicesum == point)
gameStatus = WON;
else
if(dicesum == 7)
gameStatus = LOST;
}
if (gameStatus == WON )
{cout << "You Win!";
winMoney (wallet, 2*placeBet(wallet) );
}
else
cout << "You lose! HaHa!" << endl;
}
|