Example #1
0
// OVERRIDE 
void Hand::SortHandHighLow(std::shared_ptr<std::vector<Card>> c)
{
    if (c->empty())
    {
        printf_s("Passing a null/void vector! Cannot sort the hand high to low");
        return;
    }
    // Iterate throught the card's hand
    bool swapped;
    do
    {
        swapped = false;
        for (unsigned int i = 0; i < c->size() - 1; ++i)
        {
            if (c->at(i).GetCardValue() < c->at(i + 1).GetCardValue())
            {
                SwapCards(c, i, i + 1);
                swapped = true;
            }
            else
            {
                // Do nothing here
            }
        }
    } while (swapped);

}
Example #2
0
// Sort the Hand's cards from Highest Value to Lowest Value based on the Card.GetCardValue()
void Hand::SortHandHighLow()
{
    if (m_vHand.empty())
    {
        printf_s("m_vHand is empty! Cannot sort the hand high to low");
        return;
    }

    // Iterate throught the card's hand
    bool swapped;
    do
    {
        swapped = false;
        for (unsigned int i = 0; i < m_vHand.size() - 1; ++i)
        {
            if (m_vHand.at(i).GetCardValue() < m_vHand.at(i + 1).GetCardValue())
            {
                SwapCards( i, i + 1);
                swapped = true;
            }
            else
            {
                // Do nothing here
            }
        }
    } while (swapped);

}
Example #3
0
//Fisher-Yates Shuffle
void Shuffle(Card deck[], uint size)
{
  for(int i = 0; i < size; ++i)
  {
    int swap = rand()%(size-i) +  i;
    SwapCards(deck,i,swap);
  }
}
Example #4
0
//Selection Sort
void Sort(Card deck[], uint size)
{
  for(uint i = 0; i < size; ++i)
  {
    uint s = FindSmallest(deck,i,size);
    SwapCards(deck,i,s);
  }
}