Blackjack Game Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Blackjack Game Help

ShoxzorShoxzor Posts: 3Member
[b]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![/b]



#include
#include
#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;
}

[b]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.[/b]

#include <iostream>
#include
#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;

}


[b]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?[/b]

Comments

  • ShoxzorShoxzor Posts: 3Member
    list of output functions / descriptions

    void welcome() / displays a welcome message & instruct
    void announceCard (int theCard) / display the card just drawn ; 1-10 repersent the cards 1-10 while 11,12 & 13 rep JACK QUEEN KING ( recieves the numeric value of the card.
    void announceHand (int theHand) / display the total point value of a hand (receives the num point value of the hand )
    void announceReseult (bool side, int theHand) / Display wheither a side holds or has busted
    void whoWins (int playerHand, int houseHand) / Announce the winner ( num value of player hand & num value of house hand)

    Player Functions / used to build player's hand

    bool isPlayerHolding ( int theHand ) / Ask the player whether he wants to hold or draw another card (receives num val of current hand ) ( returns: either t / f

    int drawOneCard() / Picks a card at random assuming an infinite supply of cards ( returns numv value of card )

    [b]These are the first 7 functions of the program to be added.. I have 8 - 12 left & I need desperate help!


    email - [email protected]
    aim: shoxzorl [/b]
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]...hmmm... I do not need a compiler to see that this will not even compile![/color]
    [code]
    : bool isPlayerHolding (int theHand)
    : {
    : if (
    :
    : cout << "Do you wish to hold on " << theHand << endl;
    :
    : }
    :
    [/code]
    [color=Blue]Also, where is 'theHand' used in below code?[/color]
    [code]
    void announceHand (int theHand)
    {
    cout << "The hand's value is now " << endl;
    }
    [/code]
  • ShoxzorShoxzor Posts: 3Member
    I understand that it will not compile, because i am not sure how to write that next function...
    im lost?



    &&


    I really don't know?
    Do i need to int it in the main program?





    also; i have a header file, where all the functions are to be put?
    [b]const bool PLAYER_SIDE = true;
    const bool HOUSE_SIDE = false;
    void welcome();
    void announceHand (int);
    void announceResult (bool side, int theHand);
    void whoWins (int playerHand, int houseHand);
    bool isPlayerHolding (int theHand);
    int drawOneCard();[/b]
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [color=Blue]I am guessing that it is supposed to be just printed:[/color]
    : [code]:
    : void announceHand (int theHand)
    : {
    : cout << "The hand's value is now " [color=Red]<< theHand[/color] << endl;
    : }
    : [/code]
    [color=Blue]I am guessing (again) that this function should ask player if he/she wants to hold that hand:[/color]
    [code]
    bool isPlayerHolding (int theHand)
    {
    cout << "Do you wish to hold on " << theHand << endl;

    // get here player input, probably as text and then check if player
    // said "yes" then return true and if player said "no" then
    // return false.
    }
    [/code]
    [color=Blue]I am not sure of any other logic here - did not play this game much. How does building House hand works? I think initially there should be a pair of cards for each House and Player. After this I am not sure of any logic.[/color]
Sign In or Register to comment.