Thread: How would I do this?

  1. #1
    Unregistered
    Guest

    How would I do this?

    Hello,
    How would I take the below fuction and make it so you get two cards to start with and then It gives you the option to draw another?
    Thank You For Your Help,
    Matt

    int DealUser(){
    int NumCards;
    cout <<"How Many Cards Do You Want? ";
    NumCards=2;
    cout <<"You: ";
    int CardCount, Card, SumCards = 0;
    do{
    Card = DealCard();
    cout<<Card<<" ";
    SumCards+=Card;

    cout <<"="<<SumCards<<endl;
    char dealcardanswer;
    cout <<"Another Card? (y,n)";
    cin >> dealcardanswer;
    }while (dealcardanswer != 'n');
    return(SumCards);
    }

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I'd write the actual code for you. but I'm a little short on time. Give them two cards, input their option, if yes, draw, if not, just move on. Hope this helps.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    int DealUser(){
    int NumCards;
    cout <<"How Many Cards Do You Want? ";
    NumCards=2;
    cout <<"You: ";
    int CardCount, Card, SumCards = 0;
    do{
    Card = DealCard();
    cout<<Card<<" ";
    SumCards+=Card;

    //here is where you will deal another
    Card = DealCard();
    cout<<Card<<" ";
    SumCards+=Card;


    cout <<"="<<SumCards<<endl;
    char dealcardanswer;
    cout <<"Another Card? (y,n)";
    cin >> dealcardanswer;
    }while (dealcardanswer != 'n');
    return(SumCards);
    }

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    two comments:

    1. why are u asking how many cards the user wants in a text output when they cannot affect how many cards are drawn.

    2. make sure u check that the drawn card has not already been put on the table.

Popular pages Recent additions subscribe to a feed