My names Rich;
I'm new to these forums, needing some help on my Blackjack C++ Game..
Its a final project && I'm basically clueless
Appreciate the help in advance!
#include <iostream>
#include <ctime>
#include "blackjack.h" // should contain all function prototypes
// and global variables and constants
using namespace std;
int main()
{
// Initialize random number generator
srand(time(0));
// Display welcome message and game rules
welcome();
// Show the house's open card
bool houseHasBigAce = false;
int houseHand = drawOpenHouseCard(houseHasBigAce);
// Then, build the player's hand
int playerHand = buildPlayerHand();
announceResult(PLAYER_SIDE, playerHand);
// Unless the player has busted, build the house's hand
if( playerHand <= 21 ) {
houseHand = buildHouseHand(houseHand, houseHasBigAce);
announceResult(HOUSE_SIDE, houseHand);
}
// Inform the player of the final result
whoWins(playerHand, houseHand);
system("pause");
return 0;
}
The main program of it has been written for us;
& the only thing we have to do is write the remaining functions to complete it.
#include <iostream>
#include <ctime>
#include "test.h" // should contain all function prototypes
// and global variables and constants
using namespace std;
using std::cout;
using std::endl;
int main()
{
welcome();
return 0;
}
void welcome()
{
cout << "Welcome to the game of BLACKJACK " << endl;
cout << " 1. The deck contains an infinite supply of cards" << endl;
cout << " 2. The goal of the game is to assemble a hand whose numerical point value is as close to 21" << endl;
cout << " without going over. Whoever gets closes to 21 without going over wins. " << endl;
cout << " 3. Aces are worth either 1 point or 11 points at the players dicretion. Picture cards are worth" << endl;
cout << " 10 points. All other cards are worth a number of points equal to their numerical value. " << endl;
cout << " 4. The dealer must draw on 16 or less and hold on 17 or more. " << endl;
cout << "LET'S START THE GAME !" << endl;
}
void announceCard(int theCard)
{
switch (theCard)
{
case 1:
cout << "An Ace ";
break;
case 2:
cout << "A Deuce ";
break;
case 3:
cout << "A Three ";
break;
case 4:
cout << "A Four ";
break;
case 5:
cout << "A Five ";
break;
case 6:
cout << "A Six ";
break;
case 7:
cout << "A Seven ";
break;
case 8:
cout << "A Eight ";
break;
case 9:
cout << "A Nine ";
break;
case 10:
cout << "A Ten ";
break;
case 11:
cout << "A Jack ";
break;
case 12:
cout << "A Queen ";
break;
case 13:
cout << "A King ";
break;
}
}
void announceHand (int theHand)
{
cout << "The hand's value is now " << endl;
}
void announceResult (bool side, int theHand)
{
if (theHand > 21) {
if (side == PLAYER_SIDE)
cout << "Player Busted!" << endl;
else
cout << "House Busted!" << endl;
}
else {
if (side == PLAYER_SIDE)
cout << "Player Holds on "<< theHand << endl;
else
cout << "House Holds on " << theHand << endl;
}
}
void whoWins (int playerHand, int houseHand)
{
if (playerHand > houseHand) {
cout << "Player Wins! " << endl;
}
else
{
cout << "House Wins! " << endl;
}
}
bool isPlayerHolding (int theHand)
{
if (
cout << "Do you wish to hold on " << theHand << endl;
}
This is currently my list of functions that I have added to it..
I have a project sheet that walks me through and gives me the functions, but i don't really understand what they are to do etc?