From 6c83506cb44b1d20f66df404f0b6468b0e291b6b Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Tue, 25 Jun 2019 17:55:13 -0500 Subject: Do a thing: --- ee1301/wk6/lab5/strap012_lab5_w_1.cpp | 148 +++++++++++++++++----------------- 1 file changed, 74 insertions(+), 74 deletions(-) (limited to 'ee1301/wk6/lab5/strap012_lab5_w_1.cpp') diff --git a/ee1301/wk6/lab5/strap012_lab5_w_1.cpp b/ee1301/wk6/lab5/strap012_lab5_w_1.cpp index 2c3a92f..9f5e285 100644 --- a/ee1301/wk6/lab5/strap012_lab5_w_1.cpp +++ b/ee1301/wk6/lab5/strap012_lab5_w_1.cpp @@ -1,75 +1,75 @@ -#include -//#include //Needed if using MinGW - -class DeckOfCards { -private: - int index=0, deck[52]; -public: - DeckOfCards(); - void shuffle(); - int dealCard(); -}; - -void showHand(int hand[], const int size); -int main() { - srand(time(NULL)); - const int size=4; //Size can be changed for larger hands - DeckOfCards deck; - int hand[size]; - for (int i=0; i<13; i++) { - for (int j=0; j1; i--) { - j = rand() % 50 + 1; - if (j < i) { - temp=deck[i]; deck[i]=deck[j]; deck[j]=temp; - } - } -} - -//Function to deal the card when asked by grabbing from the deck and shuffling if such card does not exist. -//Returns the card drawn from the deck -int DeckOfCards::dealCard() { - index++; - if (index>=52) { - index=0; - shuffle(); - } - return deck[index]; +#include +//#include //Needed if using MinGW + +class DeckOfCards { +private: + int index=0, deck[52]; +public: + DeckOfCards(); + void shuffle(); + int dealCard(); +}; + +void showHand(int hand[], const int size); +int main() { + srand(time(NULL)); + const int size=4; //Size can be changed for larger hands + DeckOfCards deck; + int hand[size]; + for (int i=0; i<13; i++) { + for (int j=0; j1; i--) { + j = rand() % 50 + 1; + if (j < i) { + temp=deck[i]; deck[i]=deck[j]; deck[j]=temp; + } + } +} + +//Function to deal the card when asked by grabbing from the deck and shuffling if such card does not exist. +//Returns the card drawn from the deck +int DeckOfCards::dealCard() { + index++; + if (index>=52) { + index=0; + shuffle(); + } + return deck[index]; } \ No newline at end of file -- cgit v1.2.3