I am trying to learn c++ so i am making a poker app.
I don't know what its going to do yet.
I think run simulations and calculate poker stuff or something.
I made a card class, and a deck class (a vector of cards).
So far my deck can deal a card. the cards are represented by integers.
I was going to use enums but it made more sense to me with ints.
here is the card class:
Code:
class Card
{
public:
Card(int R, int S);
Card();
~Card();
int getRank();
int getSuit();
void setRank(int R);
void setSuit(int S);
void printCard();
private:
int rank;
int suit;
};
It keeps track of the rank and suit with integers.
I like this for when i start evaluating poker hands.
printCard() is a function that changes the integers to chars for display.
The deck class is not done yet but its off to a good start.
I need to think of other things a deck can do, like shuffle the entire deck and shuffle some number of cards in the deck, this is only the start of it.
here is the (unfinished) deck class:
Code:
class Deck
{
public:
Deck();
~Deck();
void displayDeck();
int cardsInDeck();
Card dealCard();
int cardsDealt();
void displayCardsDealt();
void newDeck();
void shuffleCards();
private:
std::vector<Card> deck;
std::vector<Card> dealt;
};
Here is the constructor for the deck class:
Code:
Deck::Deck()
{
for(int s=0; s < 4; s++)
{
for( int r=0; r < 13; r++)
{
deck.push_back(Card(r,s));
}
}
};
This is kinda cool and dirty, it works but will freak out if the deck is empty.
I guess I should check for that before dealing a card... whatever.
Code:
Card Deck::dealCard()
{
dealt.push_back(deck.at(deck.size()-1));
deck.pop_back();
return dealt.at(dealt.size()-1);
}
I will post a link to all my code when this turns into something usefull.
It will take a while. I am just thinking of everything poker and creating classes.
The board, flop, turn, player....
This will eventually be one big mess of classes.
Eventually take player ranges and run simulations, and other things when they come to mind.
I am going to go work on a shuffle function for the deck.