My names Rich;
I'm new to these forums, and I am needing some help with a project of mine, and i just can't see to figure this out..
Appreciate the help in advance if someone/someone's would be willing to help me out, or at least look at this & guide me thru it just something would be greattt....
Assignment.. Basic Blackjack C++ Program; Using 2005 Visual Studio;
We have the basic main program below written for us & we are to complete & add the several following functions in completing it.
#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;
}
Now, i created a test program in a seperate file to see if when i wrote the addition functions they would compile, because without writing them all at once, the whole thing wouldn't compile
#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;
}
cout << "Do you wish to hold on " << theHand << endl;
}
^ bool isPlayerHolding is not complete. only started.
&& These functions may be wrong>?
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?
void welcome() / displays a welcome message & instructions
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 )
These are the first 7 of 13 functions on our assignment sheet, i have completed several or at least tried.
Last thing, header file also is included.. place all of the functions in there along with const
Perhaps you should first define the steps the functions should take in plain English. That usually helps when you're new to a language (or to programming altogether).