How would I do this?

This is a discussion on How would I do this? within the C++ Programming forums, part of the General Programming Boards category; Hello, How would I take the below fuction and make it so you get two cards to start with and ...

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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,136
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21