i need help making a black jack game

i have a program done that will randomly pull the cards from a standard deck, this said i'm drawing a blank when it comes time to show dealer and players cards in their respective hands
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

const int NUMBER_OF_CARDS = 52;

// Shuffle the elements in an array
void shuffle(int list[], int size)
{
srand(time(0));
for (int i = 0; i < size; i++)
{
// Generate an index randomly
int index = rand() % NUMBER_OF_CARDS;
int temp = list[i];
list[i] = list[index];
list[index] = temp;
}
}

int main()
{
int deck[NUMBER_OF_CARDS];
const string suits[] = {"Clubs", "Diamonds", "Hearts", "Spades"};
const string ranks[] = {"Ace", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King"};

// Initialize cards
for (int i = 0; i < NUMBER_OF_CARDS; i++)
deck[i] = i;

// Shuffle the cards
shuffle(deck, NUMBER_OF_CARDS);

// Display the first four cards
for (int i = 0; i < 4; i++)
{
cout << ranks[deck[i] % 13] << " of "
<< suits[deck[i] / 13] << endl;
}
system ("pause");
return 0;
}
be careful here:
 
<< suits[deck[i] / 13] << endl;  //  52/13 is 4, suits have an array index of 0-3 


I know that you are only going to show the first four cards, but this logic is not good for showing the whole deck.

Last edited on
as it stands when compiled this program shows 4 cards. i need to break it up so that it shows 2 cards for player and initially it would only show one card for the dealer. then the rules of black jack would apply. the dealers second card would only be revealed when the player stands or busts. then the dealer hand would begin(value of face up card + value of face down card that flips to face up would determine if the loop continues. the rules for the loop could be in a if else loop for example
if
dealerTotal<=16
hit
else
dealerTotal>=17
stand
else
dealerTotal>21
bust
additionally after this is a completed program i will have to break it up as i have to use visual studio and make this an application. i have already setup my visual studio i just need to put the code behind each button.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef BLACJACKPLAYERS
#define BLACKJACKPLAYERS

//holds the cards
#include <vector>

//class participant is a base class for each player and dealer
class Participant
{
public:
    Participant(){};
    virtual ~Participant(){};
   
    //gives a card to the participant
    void GiveCard(int Card){};
    
    //displays the Participants hand
    void DisplayHand(){};    

    //clears the hand 
    void NewHand(){};

private:

   std::vector<int> Cards;  //the cards the participant currently has

};

//derives from the base Participant to allow for AI
class Dealer : public Participant
{
    Dealer(){};
    ~Dealer(){};

    //Executes the Dealer AI
    void DoAI(){};
};
#endif 
Topic archived. No new replies allowed.