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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started