hello all, i am working on a really simple game that doesn't require any input from the user, except to run or end the program, and i am completely stuck. i could really use some help here.
i have to use user-defined functions and I can't figure out how to call each of them in main().
the program needs to display two cards in numerical form from 2 to 11 for the player and the dealer, then total the two cards. If the player is over 21 he loses, and same for the dealer; but if the dealer is under 17 he must draw again.
the code is below, let me know if i need to give more info
i have to use user-defined functions and I can't figure out how to call each of them in main().
the program needs to display two cards in numerical form from 2 to 11 for the player and the dealer, then total the two cards. If the player is over 21 he loses, and same for the dealer; but if the dealer is under 17 he must draw again.
the code is below, let me know if i need to give more info
Code:
#include<iostream>
#include<cstdlib>
#include<time.h>
using namespace std;
int randomDraw(int card);
//returns random number from 2 to 11
bool isBust(int hand);
//returns true if the value of hand exceeds 21.
void playerWins(int handP);
//displays the fact player won.
void dealerWins(int handD);
//displays the fact dealer won
bool mustDraw(int dealer);
//returns true if the value of dealers hand is less than 17.
int drawoneCard(char[], int, bool);
//returns true if the value of dealers hand is less than 17.
int main()
{
cout << "WELCOME TO MY ACE-HIGH GAME " << endl;
//randomDraw(int card);
//bool isBust(int hand);
//void playerWins(int handP);
//void dealerWins(int handD);
//bool mustDraw(int dealer);
//int drawoneCard(char[], int, bool);
return 0;
}
//returns randomly generated card value from 2 to 11.
int randomDraw(int card)
{
srand (time(NULL));
card = (rand()%10+2);
return(card);
}
//returns true if the value of hand exceeds 21.
bool isBust(int handP)
{
if(handP>21)
return true;
else
return false;
}
//displays the fact player won.
void playerWins(int handP)
{
cout << "Player Wins " << endl;
}
//displays the fact dealer won
void dealerWins(int handD)
{
cout << "Dealer Wins " << endl;
}
//returns true if the value of dealers hand is less than 17.
bool must_draw(int dealer)
{
if(dealer<17)
return true;
else
return false;
}
//returns true if the value of dealers hand is less than 17.
//int drawoneCard(char[], int , bool)
//{
// return;
//}