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
|
#include <iostream>
#include <fstream>
#include <iostream.h>
#include <string.h>
using namespace std;
/* *********************************************************************************************************** */
void instructions (void);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int startgame (int money, bool deck[4][13]);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int bet_taker (int money);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int card_pick (int &i, int &j, bool deck [4][13]);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int player_calculator (int player_cards [10]);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int dealer_calculator (int dealer_cards [10]);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
void card_displayer (int i, int j, int turn);
/* *********************************************************************************************************** */
/* *********************************************************************************************************** */
int turn_changer (int &turn);
/* *********************************************************************************************************** */
int main ()
{
int main_choice;
bool deck [4][13];
/* this is a bool becuase if it is true, the card can be used,
if it is false, the card has already been used*/
int money = 0;
for (int i = 0; i < 4; i = i + 1)
{
for (int j = 0; i < 13; j = j + 1)
{
deck [i][j] = true;
}
}
cout << "Welcome to the blackjack program" << endl;
cout << "If you would like to view the instructions, press 1" << endl;
cout << "If you would like to start the game, press 2" << endl;
cout << "If you would like to quit the game, press 3" << endl;
cout << "Please enter your choice now: ";
cin >> main_choice;
while ((main_choice > 3) || (main_choice < 1))
{
cout << "That is not a valid choice, make a valid choice now";
cin >> main_choice;
}
if(main_choice == 1)
{
cout << "You have chosen to read the instructions: " << endl;
instructions ();
}
if (main_choice == 2)
{
//call the game starting function
cout << "You have chosen to start the game" << endl;
money = startgame (money,deck);
}
if (main_choice == 3)
{
cout << "Thank you for playing the game of blackjack" << endl;
system ("pause");
exit (0);
}
}
void instructions (void)
{
//add instructions here
}
int startgame (int money, bool deck[4][13])
{
int game_option;
int bet;
int i;
int j;
int person_count = 0;
int dealer_count = 0;
int player_cards [10];
int dealer_cards [10];
int turn = 0;
int player_card_number = 0;
int dealer_card_number = 0;
for (int clear = 0; clear < 10; clear = clear + 1)
{
player_cards [clear] = 0;
dealer_cards [clear] = 0;
}
if (money == 0)
{
cout << "You have been awarded 500 dollars, because you had none before" << endl;
money = 500;
}
cout << "If you would like to be dealt a hand, press 1" << endl;
cout << "If you would like to see how much money you have, press 2" << endl;
cout << "If you would like to exit to the main menu, press 3" << endl;
cout << "Make your choice now: ";
cin >> game_option;
while ((game_option > 3) || (game_option < 1))
{
cout << "That is not a valid choice, make a valid choice now: ";
cin >> game_option;
}
if (game_option == 1)
{
bet = bet_taker (money);
money = money - bet;
card_pick (i,j,deck);
card_displayer (i,j,turn);
turn_changer (turn);
}
if (game_option == 2)
{
cout << "The amount of money you have is " << money << "dollars" << endl;
system ("pause");
}
if (game_option == 3)
{
cout << "Thank you for playing the game of blackjack" << endl;
return money;
}
}
int bet_taker (int money)
{
int bet;
cout << "How much money would you like to bet? ";
cin >> bet;
while ((bet > money) || (bet < 1))
{
cout << "That is an invalid bet! " << endl;
cout << "Please enter a bet that is greater than zero, and within the amount of money you have!" << endl;
cout << "Enter a valid bet here: ";
cin >> bet;
}
}
int card_pick (int &i, int & j, bool deck [4][13])
{
do{
//insert code for picking a random card here (with i amd j)
}while (deck [i][j] == false);
deck [i][j] == false;
}
int player_calculator (int player_cards [10])
{
//calculate the value of player cards here
}
int dealer_calculator (int dealer_cards [10])
{
//calculate the value of dealer cards here
}
void card_displayer (int i, int j, int turn)
{
string who_turn;
string suit;
string face_cards;
if (i == 0)
{
suit = "diamond";
}
if (i == 1)
{
suit = "clubs";
}
if (i == 2)
{
suit == "hearts";
}
if (i == 3)
{
suit == "spades";
}
if (turn == 0)
{
who_turn = "dealer";
}
if (turn == 1)
{
who_turn = "player";
}
if (j == 0)
{
face_cards = "ace";
}
if (j == 10)
{
face_cards = "jack";
}
if (j == 11)
{
face_cards = "queen";
}
if (j == 12)
{
face_cards = "king";
}
if ((j > 0) && (j < 10))
{
cout << who_turn << "got a " << i << "of " << suit << endl;
}
else cout << who_turn << "got a(n) " << face_cards << "of " << suit << endl;
}
int turn_changer (int &turn)
{
if (turn == 0)
{
turn = 1;
}
else turn = 0;
return turn;
}
|