Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program to allow a user to play a modified craps games. Note: You should complete the body of the functions stubs in the

Create a program to allow a user to play a modified craps games.

Note: You should complete the body of the functions stubs in the end to complete the assignment.

The rules will be as follows:

In this game simulation, the end user will be the thrower.

The dice game simulation must use two separate random die whose results are added, so that the simulation is probability wise behaving correctly.

This program can assume all inputs are integers representing whole dollar amounts.

1) Ask the user for a stake amount (initial amount of money available to bet).

Check to make the sure user enters a correct number (over 0). State a descriptive error to re-prompt the user if the stake amount is not a correct amount like a negative number).

2) Ask the thrower for their bet.

The amount of money the thrower has to bet (the stake amount) should be displayed before the throw to help the thrower make a bet. You must verify correct bets (ex: bet amount must be greater than or equal to than stake amount that is left). The thrower must have money to be able to bet on a throw (stake money left > 0) or the game will post a message and automatically end.

At this point, if the thrower wishes to stop the game, then the thrower should enter a bet of 0.

3) Throw a pair of dice.

A message should display telling the bettor to throw the dice by pressing any key. When the thrower wins, twice the bet money is returned back into the throwers total stake. When the thrower loses, the bet money is deducted from the throwers total stake.

Throw results:

a) If the total value of the dice is 7 or 11, the thrower is an instant winner.

b) If the total value of the dice is 2, 3, or 12, the thrower is an instant loser.

c) If the total is anything else, remember this total, it is called the point. The thrower throws again:

i) If the new point throw total is equal to the point, the thrower wins.

ii) If the new point throw total is a 7, the thrower loses.

iii) If the new point throw total is anything else than a 7 or the point,

the thrower must keep throwing until the thrower wins by getting a point roll or loses by getting a 7.

d) When the thrower is done with each cycle of throwing, the game should display the new adjusted stake amount.

Lets own a casino!

4.) When throwing cycle is done an ending condition occurring (no money left, win or lose), the program will report the final stake amount the thrower has left and how many total throws the thrower made during the game.

Recall that the game ends when:

I. The thrower ends the game by entering a zero bet at the start of a throw cycle.

II. The stake ends up at a zero amount, the program automatically ends the game.

Use the output solution sample as a guide in designing the program.

image text in transcribed

Complete the following body of the functions stubs to complete the assignment:

// Roll Bones.cpp : Defines the entry point for the console application.

#include "stdafx.h" #include #include #include #include

using namespace std;

unsigned askForInititalStakeAmountFunc(); unsigned askForBetDonePlayingFunc (unsigned stakeUns); unsigned rollDemBonesFunc (unsigned &rollCountUns); void evaluateRollFunc (unsigned diceRollResultsUns, unsigned &rollCountUns, unsigned &stakeUns, unsigned betUns); bool pointRollDemBonesFunc (unsigned pointUns, unsigned &rollCountUns);

int main() { unsigned betUns, rollCountUns = 0, diceRollResultsUns, stakeUns = askForInititalStakeAmountFunc();

do { betUns = askForBetDonePlayingFunc(stakeUns); if (betUns != 0) { diceRollResultsUns = rollDemBonesFunc(rollCountUns); evaluateRollFunc(diceRollResultsUns, rollCountUns, stakeUns, betUns); } } while ((betUns != 0) && (stakeUns != 0));

cout

if (betUns == 0) cout

cout

getchar(); //freeze screen return 0; }

/* Name: askForInitialStakeAmountFunc Function Purpose : Retrieves the initial money from prompting the user Function Design: Checks if the input stake amount the player eneters a proper amount. Inputs: None Outputs: By function name an unsigned integer that's the stake amount */

unsigned askForInititalStakeAmountFunc() { return 0; }

/* Name: askForBetDonePlayingFunc Function Purpose : Asks for what the player will bet and checks for validity Function Design: Checks for valid entry has been entered Inputs: stakeUns - The total stake amount Outputs: By function name an unsigned integer that's the bet amount */

unsigned askForBetDonePlayingFunc(unsigned stakeUns) { return 0; }

/* Name: rollDemBonesFunc Function Purpose: generates a random number for a roll and increment rollCountUns Function Design: Prompts the user to throw the dice Using rand() generates 2 random variables from 1 to 6 and adds to simulate dice throw Inputs/Outpuut: &rollCountUns - Reference of total rolls count in game Outputs: By function name an unsigned integer that's the sum of the two rolled dice */

unsigned rollDemBonesFunc(unsigned &rollCountUns) {

return 0; }

/* Name: evaluateRollFunc Function Purpose: Check for a winning roll, a losing roll, or a point roll result Function Design: 2, 3, 12 loses 7, 11 winner anything else executes point rolls Inputs: diceRollResultsUns - The dice roll sum Input/Output: &rollCountUns - Reference to tally of total rolls &stakeUns - Reference to the total at stake Inputs: betUns - The placed bet */

void evaluateRollFunc(unsigned diceRollResultsUns, unsigned &rollCountUns, unsigned &stakeUns, unsigned betUns) {

}

/* Name: pointRollDemBonesFunc Function Purpose: Executes the point rolls Function Design: Displays the point value. Uses rollDemBonesFunc until the point or 7 is the result Complex Elements: rollCountUns is passed from this function to rollDemBonesFunc() Inputs: pointUns - The point set by the first roll &rollCountUns - Reference to total roll count Outputs: Returns true if wins or false if loses */

bool pointRollDemBonesFunc(unsigned pointUns, unsigned &rollCountUns) {

return 0; }

What is your stake amount? 100 Current Stake Amount: 100 What will you bet? 50 Press any key to throw the dice Die 01 is 6 Die 02 is 2 The dice throw results:8! The point is 8 Throw em again and hope that luck's on your side! Press any key to throw the dice Die 01 is 1 Die 02 is 2 The dice throw results 3! The point is 8 Throw em again and hope that luck's on your side! Press any key to throw the dice Die 01 is 5 Die 02 is 3 The dice throw results:8! We've got ourselves a winner! Current Stake Amount: 200 What will you bet? 500 Sorry, can't bet more than your stake! Current Stake Amount: 200 What will you bet ? 200 Press any key to throw the dice Die 01 is 1 Die 02 is 1 The dice throw results 2! Sorry, you lose Out of money, Game ends Roll Count Final Stake Amount : 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Development Of Knowledge Framework For Affective Content Analysis

Authors: Swarnangini Sinha

1st Edition

B0CQJ13WZ1, 979-8223977490

More Books

Students also viewed these Databases questions

Question

Are there any questions that you want to ask?

Answered: 1 week ago