Server IP : 172.16.15.8 / Your IP : 3.138.32.53 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/bafreeman/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Pirate's Gold Game // August 2008 // Benjamin Freeman #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> #include "cardclass.cpp" void PlayPirateGame(DeckType deck); int main() { DeckType deck; srand(time(0)); deck.Shuffle(); PlayPirateGame(deck); return 0; } void PlayPirateGame (DeckType deck) { typedef CardType HandType[DECKSIZE]; HandType hand1, hand2; int tablecards, i,j,l,g,m; cout << "Pirate's Gold Game\n\n"; cout << "Orignal Cards on Table:\n"; for (i=0; i < 8; i++) // Select 8 cards from the deck. { hand1[i] = deck.DrawCard(); hand1[i].Print(); if (i==3) cout << "\n"; else cout << " "; hand2[i]=hand1[i]; } // Time to see if any of the cards match. for(l=1; l<23; l++) { for (g=0; g<8; g++) { for (m=1; m<8; m++) { if (hand1[g].EqualFace(hand2[m])) // Two cards do match { hand2[m]=deck.DrawCard(); hand1[g]=deck.DrawCard(); } } } cout << " \n------------------------" << endl; cout << "Round " << l << endl; for(j=0; j<8; j++) { hand2[j].Print(); if (j==3) cout << endl; else cout << " "; } if (deck.IsEmpty()) cout << "\nYou've won"; } cout << endl; }