Question: Write a function named rollDice that simulates the tossing of a multi-sided dice. It should take in parameters that depict how many sides (faces) are

Write a function named rollDice that simulates the tossing of a multi-sided dice. It should take in parameters that depict how many sides (faces) are on the dice (numbered 1 to the number of sides). When you call the function, it should generate a random number in the range of 1 through the number of dice sides. It should return the number rolled. Then you should have another function called playGame. This function take in a parameter that lists the goal of the game. You will alternate roles for each of two players, by calling rollDice (from playGame). The first player to get a score that is equal to that number without going over wins. The function should show that status of each players roles. Then it should return 1 or 2 (representing whether player 1 or player 2 won the game. Your main function should call playGame. Then it should print out which player won the game (from main).

Implementation detail 1: You should place the function prototypes in a file called Functions.h The function prototype has a semi-colon at the end. e.g

int rollDice (int sides);

Implementation detail 2: Your functions.h file should have a guard against duplication, e.g.

#ifndef FUNCTIONS_H

#define FUNCTIONS_H

(function prototypes)

#endif

Implementation detail 3: Your functions.cpp AND your lastnamefirstLab05.cpp should

#include Functions.h.

Remember that you should not #include.cpp files!

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!