خرید بک لینک

Vote count: -1

The problem in this is that when I am compiling it, the switch statement is working, which is good, but it seems that when I input 'y' the do-while loop is not executing. Forgive me, as I am a begier to c++, but is there any way I can fix this? Here is the code:

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
bool cootieInComplete(int numBody, int numHead, int numAntea, int numWings, int numStinger, int numLegs, int numEyes);
int randomRoll();

int main()
{

        srand(time(0));
        int looper=0, diceRoll, numBody=0, numHead=0, numAntea=0;
        int numWings=0, numStinger=0, numLegs=0, numEyes=0;
        char yay_or_nay;
        cout << "Do you want to play a game of cootie?n";
        cout << "Enter 'y' or 'n': ";
        cin >> yay_or_nay;
        switch (yay_or_nay)
        {
            case 'y':

                do
                {
                    ++looper;
                    diceRoll=randomRoll();
                    if (diceRoll==1)
                    {
                        numBody++;
                    }
                    if (diceRoll==2&&numBody==1)
                    {
                        numHead++;
                    }
                    if (diceRoll==3&&numHead==1)
                    {
                        numAntea++;
                    }
                    if (diceRoll==4&&numBody==1)
                    {
                        numWings++;
                    }
                    if (diceRoll==5&&numBody==1)
                    {
                        numStinger++;
                    }
                    if (diceRoll==6&&numBody==1)
                    {
                        numLegs++;
                    }

                    if (diceRoll==7&&numHead==1)
                    {
                        numEyes++;
                    }
                } while (cootieInComplete(numBody, numHead, numAntea, numWings, numStinger, numLegs, numEyes));
                cout << "Cootie complete in " << looper << " rolls." << endl;
            break;

            case 'n':
                cout << "Bye!";
            break;
        }
        retu 0;
    }

    bool cootieInComplete(int numBody, int numHead, int numAntea, int numWings, int numStinger, int numLegs, int numEyes)
    {
        if (numBody!=0&&numHead!=0&&numAntea>=2&&numWings>=2&&numStinger!=0&&numLegs>=4&&numEyes>=6)
        {
            retu false;
        }
        else
        {
            retu true;
        }
    }

    int randomRoll()
    {
        using namespace std;
        int fergie=rand()%7+1;
        retu fergie;
    }

asked 32 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: شنبه 26 تير 1395 ساعت: 1:53

صفحه بندی