#include #include "card.h" #include "list.h" #include #include using namespace std; void deal(List & Deck, List & hand, int card_count); int main () { card one; List Deck; List player1, player2; int i; int j; srand(time(NULL)); for(i=Hearts;i<= Diamonds;i++) { for (j=Two; j<= Ace; j++) { one.set_card(SuiteType(i),ValueType(j)); // cout << "Inserting " << one << endl; Deck.Insert(one); } } // this is a debugging step. // Deck.Print(); deal(Deck, player1,10); deal(Deck, player2,10); player1.Sort(); player2.Sort(); cout << "Player 1's hand: " << endl ; player1.Print_oneline(); cout << endl<< endl << "Player 2's hand: " << endl ; player2.Print_oneline(); cout << endl << endl; Deck.Sort(); cout << "The remaining Deck is " << endl; Deck.Print_oneline(); cout << endl; } void deal(List & Deck, List & hand, int card_count){ int suite; int value; card c; int count=0; // cout << "In deal" << endl; while (count < card_count) { do{ suite = rand() % 4; value = rand() % 13; c.set_card(SuiteType(suite),ValueType(value)); // cout << "Checking " << c << endl; } while (!Deck.IsPresent(c)) ; // cout << "Taking " << c << " from the deck" << endl; Deck.Delete(c); // cout << "Adding " << c << " to the hand " << endl; hand.Insert(c); count ++; } }