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
|
#include<limits>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<ctime>
#include<iomanip>
#include <algorithm>
using namespace std;
void seedADeckOfCards(vector<int>&);
void dealFiveCardHand(vector<int>&, int [], char [], int [], char [],
const double, const double);
void exchangeCards(int[], vector<int>&, int&, char [], const int [],
const char[], const double, const double);
bool wantToSwapcards();
void outputDeck(const vector<int>&);
void showHand(const int[], const char[]);
void showWinningsMenu();
void getBet(const double, double&);
void displayTotalAndBet(const double, const double);
void displayOriginalHand(const int [], const char []);
void displayOrigAndNewHand(const int [], const char [],
const int [], const char []);
const int HAND = 5;
string hold;
int main()
{
char suit[HAND];
int num = time(0);
srand(num);
vector<int> cardDeck;
int cardHand[HAND], orignalHand[HAND];
char originalSuit[HAND];
double total = 1000;
double bet = 0;
cout << setprecision(2) << fixed << showpoint;
char playAgain;
do
{
system("CLS");
showWinningsMenu();
getBet(total, bet);
system("CLS");
showWinningsMenu();
displayTotalAndBet(total, bet);
seedADeckOfCards(cardDeck);
std::random_shuffle(cardDeck.begin(), cardDeck.end());
dealFiveCardHand(cardDeck, cardHand, suit, orignalHand, originalSuit,
total, bet);
system("CLS");
showWinningsMenu();
displayTotalAndBet(total, bet);
displayOrigAndNewHand(orignalHand, originalSuit, cardHand, suit);
do
{
cout << "\nDo you want to play another hand? (Y or N)";
cin >> playAgain;
if(!(playAgain == 'Y' || playAgain == 'y' ||
playAgain == 'N' || playAgain == 'n'))
cout << "Invalid Entry! Enter Y or N Only";
}while(!(playAgain == 'Y' || playAgain == 'y' ||
playAgain == 'N' || playAgain == 'n'));
}while(playAgain == 'Y' || playAgain == 'y');
system ("PAUSE");
return 0;
}
void seedADeckOfCards(vector<int> &deckOfCards)
{
for(int i = 0; i < 52; i++)
deckOfCards.push_back(i+1);
}
void dealFiveCardHand(vector<int> &deckOfCards,
int cardHand[],
char suit[],
int originalHand[],
char originalSuit[],
const double total,
const double bet)
{
int card;
int dealFromBack = 51;
for(int i = 0; i < HAND; i++)
{
cardHand[i] = deckOfCards[dealFromBack] % 13 + 1;
cout << "CARD " << (i+1) << " = ";
cout << setw(3) << cardHand[i] << " ";
suit[i] = deckOfCards[dealFromBack]%4+3;
cout << suit[i] << endl;
deckOfCards.pop_back();
--dealFromBack;
originalHand[i] = cardHand[i];
originalSuit[i] = suit[i];
}
exchangeCards(cardHand, deckOfCards, dealFromBack, suit,
originalHand, originalSuit, total, bet);
cout << "Your Original Hand: \n";
displayOriginalHand(originalHand, originalSuit);
cout << "Your New Hand: \n";
showHand(cardHand, suit);
cout << endl;
}
|