This program will contain 6 functions to be called from main and from another function. The functions will be contained in two files: Functions.h, which contains the function prototypes, and Functions.cpp, which will contain the function implementations (or bodies). Do not forget to put include guards in the Functions.h file. Begin the program by declaring variables and then calling the function WriteHeader. This function will display your name, the program title and objective. Then call ShowRules, which explains the rules. See the random number generator function. This is only done once. Call AskForName to get the player’s name. This functions returns a string with the player’s name. Open a do while or while loop. This is the “play loop,” which allows the user to play craps as many times as he/she wants. Call the function AskForBet to retuun the amount of the user’s bet. The bet minimum is $5.00 and can only be increased in increments of $5.00. The amount of the bet is a double or a float. Assume that the player begins with a balance of $200.00 in his/her pocket. Call ThrowDice, which displays the sum of the values of the faces of the two dice rolled. ThrowDice returns the sum to main. Check the sum to see if the user won, lost, or has to continue. If the player continues, call PlayPointRound, passing the function the point (or the sum of the two dice thrown). PlayPointRound opens a do while loop and calls ThrowDice until the sum is the point or 7. If the point was thrown, it returns true, for a win. If 7 was thrown, it returns false. Keep track of the player’s money balance as he/she plays craps by calling UpdateBalance. Also keep track of the number of wins and losses. Ask the user if s/he wants to play again. Be sure to give the user the choices as an answer. When the user is finished, display a summary of the user’s games, starting with the user’s name, the number of games won, the number of games lost, and the final money balance. Use precision and $ to show money correctly. Then say thank you and goodbye. Function prototypes: Return type Function Name Function Parameters Description void WriteHeader ( ) Write your class header void ShowRules ( ) Display rules of our Craps Game string AskForName ( ) Ask for player’s name double AskYourBet ( ) Ask for player’s bet int ThrowDice ( ) Show sum of the two dice thrown bool PlayPointRound (int dice) Throw until the point is made or 7 double UpdateBalance (bool didWin, double bet) Keep track of the player’s balance
This
Begin the program by declaring variables and then calling the function WriteHeader. This function will display your name, the program title and objective. Then call ShowRules, which explains the rules.
See the random number generator function. This is only done once. Call AskForName to get the player’s name. This functions returns a string with the player’s name.
Open a do while or while loop. This is the “play loop,” which allows the user to play craps as many times as he/she wants. Call the function AskForBet to retuun the amount of the user’s bet. The bet minimum is $5.00 and can only be increased in increments of $5.00. The amount of the bet is a double or a float. Assume that the player begins with a balance of $200.00 in his/her pocket.
Call ThrowDice, which displays the sum of the values of the faces of the two dice rolled. ThrowDice returns the sum to main. Check the sum to see if the user won, lost, or has to continue. If the player continues, call PlayPointRound, passing the function the point (or the sum of the two dice thrown). PlayPointRound opens a do while loop and calls ThrowDice until the sum is the point or 7. If the point was thrown, it returns true, for a win. If 7 was thrown, it returns false.
Keep track of the player’s money balance as he/she plays craps by calling UpdateBalance. Also keep track of the number of wins and losses.
Ask the user if s/he wants to play again. Be sure to give the user the choices as an answer. When the user is finished, display a summary of the user’s games, starting with the user’s name, the number of games won, the number of games lost, and the final money balance. Use precision and $ to show money correctly. Then say thank you and goodbye.
Function prototypes:
Return type |
Function Name |
Function Parameters |
Description |
void |
WriteHeader |
( ) |
Write your class header |
void |
ShowRules |
( ) |
Display rules of our Craps Game |
string |
AskForName |
( ) |
Ask for player’s name |
double |
AskYourBet |
( ) |
Ask for player’s bet |
int |
ThrowDice |
( ) |
Show sum of the two dice thrown |
bool |
PlayPointRound |
(int dice) |
Throw until the point is made or 7 |
double |
UpdateBalance |
(bool didWin, double bet) |
Keep track of the player’s balance |
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 6 images