How can I make this code runnable?

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{

int players;
int input;

cout << "Welcome to the Fish Die game!";
cout << "Press 1 for rules, or 2 to start the game.";
cin >> input;

if(input == 1)
{
cout << "The rules are simple! Pick 3 dice out of the cup, then roll!\nEach fish you roll counts as 1 point,\n";
cout << "Each boot you roll counts as a strike, and any hooks can be rerolled. Each roll set aside any fish and boots. ";
cout << "and reroll 3 die again.\n The first to 12 fish wins. If you get 3 boots, you get 0, and your turn is over.";
}
else
{
cout << "How many players will there be?\nEnter a number greater than 2\n";

}
while(players >= 2 && players <= 12)
{

cin >> players;
cout << "Please enter a valid number";
}
}
void roll()
{
srand (time(0));
int s;

for (int x=1,x < 4, x++)
s = rand()%13;

if (s < 6)
{
greenDice;
}
else if)s > 5 && s<9)
{
yellowDice;
}
else if(s>8)
{
redDice;
}
}

void greenDice()
{
srand (time(0));
int g;

g = rand()%6;

if(g< 3)
{
fish;
}
else if(g>2 && g<5)
{
hook;
}
else if(g>4)
{
boot;
}
}
void yellowDice()
{
srand(time(0));
int y;

y = rand()%6;

if(y<2)
{
fish;
}
else if(y>1 && y<4)
{
hook;
}
else if(y>3);
{
boot;
}
}
void redDice()
{
srand (time(0));
int r;

r - rand()%6;

if (r<1)
{
fish;
}
else if(r>0 && r< 3)
{
hook;
}
else if(r>2)
{
boot;
}
}
int fish()
{
cout << "You rolled a fish";
++turn[1];
}
int hook()
{
cout << "You rolled a hook";
++ turn[2];
}
int boot()
{
cout <<"You rolled a boot.";
++turn[3];
}


system("PAUSE");
Post the code using code tags.

to start, the end brace of the else should be just before system("pause"); and not before the while

second you don't need loop to get one number, the code
1
2
3
4
5
6
while(players >= 2 && players <= 12)
{

cin >> players;
cout << "Please enter a valid number";
}


needs to be
1
2
3
4
5
do
{
    cout << "Please enter a number between 2 and 12" << endl;
    cin >> players;
}while( players < 2 || players > 12)


at this point run a loop for all players, in this loop use random to determine the face and depending on the face run a loop (for roll again etc) or give next user the chance.
Hope this helps you get going
Topic archived. No new replies allowed.