Each possibility has an answer. I know it should be done with switch
/ case
, but I understand that it only works with constants, and what I use is a variable, right? I tried to use it and it gave me syntax errors.
What I have done seems like a fudge.
I explain what it is supposed to do: when I invoke the function I pass a 1 or a 0. If I pass a 1, I am in the field of positive responses and if something else happens (in this case a 0) , in the of the negatives. Then within each area generates a random number that goes from 1 to 4, and depending on the number that comes out must issue a response.
void respramdom(int x1)
{
if (x1 == 1)
{
int numaleatorio = randomInt2(engine);
if (numaleatorio == 1)
cout << "Very good!\n";
else if(numaleatorio == 2)
cout << "Excellent\n";
else if(numaleatorio == 3)
cout << "Nice work!\n";
else
cout << "Keep up the good work!\n";
}
else
{
int numaleatorio = randomInt2(engine);
if (numaleatorio == 1)
cout << "No. Please try again.\n";
else if (numaleatorio == 2)
cout << "Wrong. Try once more.\n";
else if (numaleatorio == 3)
cout << "Don't give up!\n";
else
cout << "No. Keep trying.\n";
}
}