I Got STUCK ON PART 7, would appreciate it if someone can help out. I have it due on sunday
Thanks

we are going to implement a slightly different version of Roulette. In our version there will be only one player and the winner is determined solely by the slot the ball stops in.

Part 2 Prototypes
Add the following prototypes to your program:
void resetBets();
int spinRouletteWheel();
void takeBets(double &money);
void playAgain(bool &decision);
void payOuts(double &house, double &player, int spin);

Part 3 Global variable
Add the following global variable to your program:
int bets[37];

Part 4 Main()
There's very little code in the main() function. The majority of the coding will be done in the functions. I've left the while-loop empty so that you can practice calling functions and get a better idea of how to use functions in your programs. It's up to you to figure out which functions to call and in what order. Hint: The body of the while-loop should contain function calls only. Also, the variables house and player represents the amount of money the house (dealer) and the player has respectively.
bool play = true;
double house = 0, player = 500;
int spin;
while(play) {
/* Place your function calls here */
}
cout << endl << endl << "Thank you for playing";
cout << endl << "House : " << house;
cout << endl << "Player : " << player;
cout << endl << endl;
Note: Some of the functions use call by reference

Part 5 resetBets();
This function will initialize all the elements of the bets array to zero

Part6int spinRouletteWheel();
This function will return a random number between 0 and 36

Part 7 void takeBets(double &money);
This function will ask the player where they would like to place a bet (0 to 36) and how much they would like to bet. The amount the player wants to bet should be subtracted from the variable money. The bet should be stored in the array in the same place as where the player would like to place his/her bet. For example, if the player would like to place his/her bet on the number 15 then the amount of the betshouldbestoredinthe15thpositionofthearray:bets[15] = amountOfBet;

Part 8 void playAgain(bool &decision);
This function will ask the user if s/he would like to play again. If the player enters 'y' or 'Y' then
decision should be set to true otherwise set it to false.

Part 9 void payOuts(double &house, double &player, int spin);
Remember, the player only earns money on the bet that was placed on the same number that the ball landed on. The payout is based on the number of bets made:
A bet on one number only, called a straight-up bet, pays 35 to 1. A two-number bet, called split bet, pays 17 to 1.
A three-number bet, called street bet, pays 11 to 1.
A four-number bet, called corner bet, pays 8 to 1.
A six-number bet, pays 5 to 1. More than six bets pays 2 to 1
All the rest of the bets go to the dealer as well as 2.63% of the player's winnings.

Part 10 while-loop
Now that you have written and tested all your functions it's time to use them. Modify the while-loop so that it calls the functions in the correct order

Recommended Answers

All 3 Replies

Double posts are discouraged,particularly when done intentionally. What don't you understand about part 7?

Hey Lerner, I didn't post twice intentionally. I wanted to add more information to the title more didn't know what to do.so far here are the codes. I'm new to C++ especially the gaming aspects

#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <time.h>

using namespace std;
  // Global variables
  int bets[37];

  // function prototypes
void resetBets();
int spinRouletteWheel();
void takeBets(double &money);
void playAgain(bool &decision);
void payOuts(double &house, double &player, int spin);


int main() {

     bool play = true;
     double house = 0, player = 500;
    int spin;
while(play) {
/* Place your function calls here */
void resetBets();
int spinRouletteWheel();
void takeBets(double &money);
void playAgain(bool &decision);
void payOuts(double &house, double &player, int spin);
}
cout << endl << endl << "Thank you for playing";
cout << endl << "House : " << house;
cout << endl << "Player : " << player;
cout << endl << endl;
// Note: Some of the functions use call by reference
// Part 5





return 0;
}
  // This function will initialize all the elements of the bets array to zero
void resetBets() {

   for (int i=0; i<37; i++ )
      bets[i] = 0;
}
// This function will return a random number between 0 and 36
int spinRouletteWheel() {
    srand(time(NULL));
     int number;
    number = (rand() % 36) + 1;
       return number;
}
// This function will ask the player where they would like to place a bet (0 to 36)
void takeBets(double &money) {
    int betPlaced;
    int amountOfBet;
    do {

        cout << "Where will you like to place a bet (0-36)?";
        cin >> betPlaced;
        cout << "How much would you like to bet ?";
        cin >> amountOfBet;

         (money - amountOfBet)= bets[]amountOfBet;


    }

}
  void playAgain(bool &decision) {
        cout << "Play again?";
        cin >> decision;

     if (decision == 'y') {
        playAgain = true;
            }
            else
               playAgain = false;
  }
  void payOuts(double &house, double &player, int spin) {







  }

you shouldn't list the return type when writing function . So in your while loop in main you should use
resetBets();
not
void resetBets();
etc.

in takeBets() you should do:
bets[where bet was placed] = amount of bet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.