1 player Black jack for mbed

Dependencies:   4DGL-uLCD-SE PinDetect mbed

deck.cpp

Committer:
jayvpoddar
Date:
2015-03-12
Revision:
0:d2e6b3ce6988

File content as of revision 0:d2e6b3ce6988:

#include "deck.h"
#include <time.h>
Deck::Deck ()
{
    int index = 0;
    for (int suit = 0; suit <= 3; suit++) {
        for (int rank =1; rank < 14; rank++) {
            cards[index]._rank= rank;
            cards[index]._suit = suit;
            index++;
        }
    }
}
void Deck::shuffleDeck()
{
    int ran;
    srand(time(NULL));
    for (int i=0; i< 52; i++) {

        ran = randomInt(i,51);

        Card::swapCards(cards,i,ran);

    }
}
int Deck::randomInt(int low ,int high)
{
    float ran = (rand()%52)*1.0;
    ran = ran/52.0;
    return (int)(((high-low)*(ran))+low);
}