1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
// Self explainatory prototypes
void loadDeck(unsigned short card[][2], const unsigned int DECKSIZE);
void dispDeck(unsigned short card[][2], const unsigned int DECKSIZE);
void shuffleDeck(unsigned short card[][2], const unsigned int DECKSIZE);
const unsigned short DECKSIZE = 52; // Deck has 52 cards
const unsigned short SUITS = 4; // Deck has 4 different suits
const unsigned short FACES = 13; // Cards have 13 different faces
// Array holding the standard suits of the cards
const std::string STDSUIT[4] = {"Clubs", "Diamonds", "Hearts", "Spades"};
// Array holding the standard faces of the cards
const std::string STDFACE[13] = {"Ace", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack", "Queen",
"King"};
int main(void)
{
unsigned short card[DECKSIZE][2] = {0}; // Entire array initialized to 0
loadDeck(card, DECKSIZE); // Call of loadDeck fuction using card array & DECKSIZE
std::cout << "Initialized Deck:" << std::endl;
}
void loadDeck(unsigned short card[][2], const unsigned int DECKSIZE) //why 2?
{
// Loop runs until c = 52 (DECKSIZE)
for(unsigned short c = 0; c < DECKSIZE; ++c)
{
// Position c, 0 is the remainder of c value divided by 13 (# of faces)
card[c][0] = c % 13;
// Position c, 1 is the division of c value divided by 13 (# of faces)
card[c][1] = c / 13;
}
}
void dispDeck(unsigned short card[][2], const unsigned int DECKSIZE);
void shuffleDeck(unsigned short card[][2], const unsigned int DECKSIZE);
|