#include <iostream>

class Card
{
public:
    int suit;
    int rank;
private:
};

#include <vector>
using namespace std;
class Hand
{
public:
    void addCard(Card c);
    bool isFlush();
private:
    vector<Card> myHand;
    int suit;
};

using namespace std;
    class Deck
{
public:
    Deck();
    void shuffleDeck();
    Hand dealCards();
private:
    vector<Card> myDeck; 
};

bool Hand::isFlush()
{
    bool result;
     // Check for a flush (all the same suit)
    if(myHand[0].suit == myHand[1].suit && myHand[0].suit== myHand[2].suit && myHand[0].suit==myHand[3].suit && myHand[0].suit==myHand[4].suit)
    {
        result = true;
    }
    else
    {
        result = false;
    }
    return result;
}
void Hand::addCard(Card c)
{
    myHand.push_back(c);
}

#include<algorithm>
    Deck::Deck()
    {
        for(int i=0; i<52;i++)
        {
            Card c;
            c.suit=i/13;
            c.rank=(i%13)+2;
            myDeck.push_back(c);
        }
    }
    void Deck::shuffleDeck()
    {
      random_shuffle(myDeck.begin(), myDeck.end());
    }
    Hand Deck::dealCards()
    {
        Hand result;
        for(int i=0;i<5;i++)
        {
            result.addCard(myDeck[i]);
        }
        return result;
    }

int main()
{
	srand(time(0));
    cout<<"Welcome to the Poker Experiment."<<endl;
    Deck deck;
    int flushCount=0;
    int numberOfHands=500000;
    for(int i=0; i<numberOfHands;i++)
    {
        deck.shuffleDeck();
        Hand hand=deck.dealCards();
        if(hand.isFlush())
        {
            flushCount++;
            deck.shuffleDeck();
        }
        else
        {
            deck.shuffleDeck();
        }
        hand = deck.dealCards();
    }
    cout<<"Flush percentage = "
        << ((double)flushCount/(double)numberOfHands)*100.0<<endl;
    cout << "Num flush: " << flushCount << endl;
    cout << "Num hands: " << numberOfHands;
    return 0;
}
