Question: Objectives: implement a real application with all the challenges associated with it Understand the idea of modular programming in C++ Understand different parts of the

Objectives: implement a real application with all the challenges associated with it

Understand the idea of modular programming in C++

Understand different parts of the game and translate this into different modules/functions of your program

Understand the idea of function stubs and when to use them

Create and test functions, one at a time

Put everything together and test everything together

Lets play Dirty Dice The assignments objective is to create a C++ based game in which one player (the user) competes against the computer where each player tries to steal the points from the opponent. Each player starts out with 100 points. The game is won by the first player to reach a set number of points. The number of points required to win the game is to be inputted by the user. Each turn, the player (human or computer) repeatedly rolls a dice until either a 3 is rolled or the player chooses to hold. If player chooses to hold, the sum of the rolls (i.e. the turn total ) is calculated. At any time during a player's turn, the player is faced with a binary decision:

0. roll - If the player rolls

a. 3 : the player steals 3 points from the opponent and it becomes the opponent's turn.

b. 1, 2, 4, 5, 6 : the number is added to the player's turn total and the player's turn continues (i.e. gets to roll again).

1. hold - The turn total is calculated, the points are subtracted from the opponents score, and it becomes the opponent's turn.

Check whether a winner has been established at the end of every turn. The player who takes the first turn in the game is chosen randomly. Do NOT use: global variables, arrays, pass by reference functions, or pass by pointer functions.

Requirements :

1) Your program should contain the following three functions (besides the main function, of course):

roll - takes in nothing. Returns a random int between 1 and 6.

oneTurn - takes in a single boolean variable to indicate whether its users or computers turn (e.g. 1 = human turn, 0 = computer turn). Plays out the entire turn until player either rolls a 3 or chooses to hold. Returns the turn total as an integer value. (Note: this function should be calling the r oll function).

loopGame - takes in a single integer value for game points goal (i.e. the number of points player needs to reach to win the game). Continues to repeat until either computer player or human player has won. Returns a boolean value (1 = computer win, 0 = human win). ( Note: this function should be calling the oneTurn function ).

2) Your program should interactively display the player and the computer choices, the dice rolls, the running turn total and the running score after each turn.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!