Game in c++

Jan 27, 2011 at 5:35pm
Hi to all, I wanted to make a simple card game in c++:
The player starts off with 100coins and 4 random cards will be given to the player, there will be 50% of possibility that the computer has higher cards than the player. (Like poker: pairs,poker ecc.) If the player wins he will gain 10coins and will be asked if he wants to play another turn but if he looses he will also loose 10coins and it will be asked if he wants to play another turn.
I haven't got any ideas on how to do this and I'm still quite a noob in c++.(I know if and else statement, algorithms and switch statement). Please help me do this game.Thanks.
Jan 27, 2011 at 5:38pm
Give an attempt at code and post it here. Surely you can do at least this:
1
2
3
4
5
6
#include<iostream>

using namespace std;

int main()
{
Jan 27, 2011 at 5:40pm
yeah lol but i don't know where to start, anyways i'll try..
Jan 27, 2011 at 5:44pm
I started off with this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <cstdlib>
#include <iostream>
#include <string.h>

using namespace std;

int main(int argc, char *argv[])
{
    
    string name;
    
    cout <<"Welcome to CardGame! What is your name?"<<endl;
    cin >> name;
    cout <<"Ok "<<name<<" let's start!"<<endl;
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


After this 4 cards will be given to the player, how do i do that?
Jan 27, 2011 at 5:44pm
You'll also need something to make the deck. You'll need to account for all 52 cards.
1
2
char suits[] = {'H', 'S', 'D', 'C'};
char value[] = {'A', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'J', 'Q', 'K'};
Jan 27, 2011 at 5:48pm
I've done something similar to this recently. I used a struct to hold each players hand.
Ex.:

1
2
3
4
5
6
7
8
struct hand
{
    char cards[5];
    char suits[5];
};

hand p1;
handp2;
Jan 27, 2011 at 5:51pm
i can't understand anything, can someone tell me where do i have to put these codes you've been giving me?


@browni3141
i don't need player1 and player2 because there will be player vs computer and the coputer cards won't be shown
Jan 27, 2011 at 8:46pm
I've managed to make it, it's really cool i like it very much. :)
Topic archived. No new replies allowed.