need assistance with a project im doing for class its matching colors basically my problem is how to go about using a delay bc u have to ask the user for how much of a delay they want but my problem is how to implemented from one void to another you will see what I mean when u see the source code and i also need some assistance displaying the whole if anyone can assist me out a little bit and explain what I have to do it would be highly appreciated thank you
void getNoColors(int* no_colors);
void setColors(int* colors, int no_colors);
void getDelay(int* no_secs);
void game(int* colors, int no_colors, int delay);
void displayColors(int* colors, int no_colors, int delay);
int main()
{
//Variable Declaration/Initialization
const int MAX_COLORS = 5;
int no_colors = 0;
int no_secs=0;
int colors[MAX_COLORS];
//Display Graphics Window
displayGraphics();
//get the # of colors
getNoColors(&no_colors);
//set the colors
setColors(colors,no_colors);
//set the delay
getDelay(&no_secs);
}
void getNoColors(int* no_colors)
{
//tell user for number of colors
do{
cout << "Enter Number of Colors (2-5): ";
cin >> *no_colors;
}while(*no_colors>5 || *no_colors < 2);
}
void setColors(int* colors, int no_colors)
{
int i = 0;
int j = 0;
bool duplicate = false;
//Initialize Random Numbers
srand(time(0));
for(i=0; i<no_colors;i++)
{
do
{
//Generate Random Number
colors[i] = rand()%5;
duplicate = false;
//Check for Duplicates
for(j=0; j<i; j++)
{
if (colors[i] == colors[j])
{
duplicate = true;
break;
}
}
}while(duplicate);
}
}
void getDelay(int* no_secs)
{
cout<<"enter the Delay: ";
cin >> *no_secs;
}
void game(int* colors, int no_colors, int delay)
{
//Declaring varibles
int i;
int obj_no;
int m;
int x=0;
int y=0;
Please use code tags by typing "code]", and please use punctuation.
Why do you have to return void? and if you can't, just use variables outside of the functions.
Example:
OK I'm sorry about that but because that is how the teacher gave it to us in order to learn to pass by pointers. I don't like the way he teaches he messes up on homework and doesn't explain the projects right that is why I was having a hard time working with the void functions.