/class deck #include #include #include enum SuitType { Hearts,Clubs,Spades,Diamonds}; enum ValueType {two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace} struct card { SuitType Suit; ValueType Value; }; class Deck { public: Deck ( ); void shuffle ( ); card deal ( ); void swap(int , int ); private: apvector < card > myDeck; }; Deck::Deck() //constructor :myDeck(52) { //-----fill vector----- int index=1; for(int loop1=1;loop1<=4; loop1++) { for (int loop2=2;loop2<=13;loop2++) { myDeck[index].Suit=loop1; myDeck[index].Value=loop2; index++; } } } void Deck::shuffle() { RandGen (a) ; RandGen (b); int c,d; for(int loop=0;loop<10000; loop++) { c=a.RandInt(1,52); d=b.RandInt(1,52); swap(c,d); } } void swap(int a, int b) { apvector temp(1); temp[1]=myDeck[a]; myDeck[a]=myDeck[b]; myDeck[b]=temp[1]; } card Deck::deal () { int abc; RandGen a; abc=a.RandInt(52); return myDeck[abc] ; }