From 7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Wed, 17 Apr 2019 17:00:57 -0500 Subject: LAB TIME OH NO --- ee1301/wk6/lab5/strap012_lab5_w_1.cpp | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 ee1301/wk6/lab5/strap012_lab5_w_1.cpp (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 new file mode 100644 index 0000000..490b54c --- /dev/null +++ b/ee1301/wk6/lab5/strap012_lab5_w_1.cpp @@ -0,0 +1,69 @@ +#include +#include + +class DeckOfCards { +private: + int deck[53]; + int index; +public: + DeckOfCards() { + for(int i=0; i<52; i++) { + deck[i]=i+1; + } + int index=0; + } + int dealCard() { + index++; + if (index>=52) { + index=0; + shuffle(); + } + return deck[index]; + } + void shuffle() { + int j=0; + int temp=0; + for (int i=51; i>1; i--) { + j = rand() % 51 + 1; + if (0 < j && j < i) { + temp=deck[i]; deck[i]=deck[j]; deck[j]=temp; + } + } + } +}; + +void showHand(int hand[], const int size); +char findCard(int card); +int main() { + const int size=4; + srand(time(NULL)); + DeckOfCards deck; + int hand[size]; + deck.shuffle(); + for (int i=0; i<13; i++) { + for (int j=0; j