When I run this code I get an error saying that the function int DiceNum(int) has too few arguments. Does anyone have any ideas? And also can anyone tell me how to loop the game to restart at the end if the user chooses?
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int randGen(int x); //function for generating random on die
int DiceNum(int num); //function for the 6 different dice rolls
short int diNumI; //dice number bet on
int moneyO = 0; //points record variable
unsigned int moneyB; //money places in bet
int main()
{
cout << "Place a bet 5, 10, 25, or 100: ";
unsigned short int dNum; //dice number choice input by the player (variable statement)
cin >> moneyB;
switch(moneyB)
{
case 5:
cout << "What number will the die land on? \n";
cin >> diNumI;
cout << "Push Enter to roll die. \n";
DiceNum();
break;
case 10:
cout << "What number will the die land on? \n";
cin >> diNumI;
cout << "Push Enter to roll die. \n";
DiceNum();
break;
}
return 0;
cin.get();
}
int randGen(int x){ //random generator function
srand(time(0));
x = 1+(rand()%6);
cout << 1+(rand()%6);
return x;
}
int DiceNum(int num){
char Lchoice[3]; //choice to play again
num = randGen();
if(diNumI == num){ //if die number guess is correct
cout << "You won! \n";
moneyO = moneyO + moneyB;
sleep(1000);
cout << "Try again?"
cin >> Lchoice;
if(Lchoice == 'yes'){
//restart
}
else if(Lchoice == 'no'){
return 0;
}
}
else if(diNumI !== num){
cout << "No the number was ";
cout << num;
cout << "Try again?\n";
cin >> Lchoice;
if(Lchoice == 'yes'){
//restart
return 1;
}
else if(Lchoice == 'no'){
return 0;
}
}
}