Making a Blackjack game..
So far I've gotten my Deck class setup as well as a function to shuffle the deck, can someone else take a look at this and tell me if I have a half decent shuffle function?
Code:
// Blackjack.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct Card
{
int suit;
int value;
};
class Deck
{
public:
int suitswap;
int valueswap;
int random;
int loopvar;
Deck()
{
int x = 0;
int y = 0;
int loopvar = 0;
while(loopvar < 52)
{
for (y = 0; y > 3; y++)
{
for (x = 0; x > 13; x++)
{
Cards[loopvar].suit = y;
Cards[loopvar].value = x;
loopvar++;
}
}
}
}
void ShuffleDeck()
{
loopvar = 0;
srand ( time(NULL) );
do
{
random = rand() % 52;
suitswap = Cards[random].suit;
valueswap = Cards[random].value;
Cards[loopvar].suit = Cards[random].suit;
Cards[loopvar].value = Cards[random].value;
Cards[loopvar].suit = suitswap;
Cards[loopvar].value = valueswap;
loopvar++;
}
while(loopvar < 52);
}
private:
std::vector<Card> Cards;
};
int _tmain(int argc, _TCHAR* argv[])
{
Deck Blackjack;
Blackjack.ShuffleDeck();
}
I guess my next step is to make a dealer class to actually deal out cards and take bets and stuff.