Advertisement
Guest User

deck program thing

a guest
Jan 31st, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. class graphics{
  6. public:
  7.     int bufferStream[60][60];
  8. public:
  9.     graphics(){
  10.         bufferStream[1][1] = 110;
  11.         cout << bufferStream[1][1];
  12.     }
  13.    
  14.  
  15. private:
  16.  
  17. };
  18. class Deck{
  19. private:
  20.     int deck[52];
  21.     int cardsInDeck = 52;
  22. public:
  23.     Deck(){
  24.         int nsetUpCounter = 0;
  25.         cout << "setting up the deck one moment" << endl;
  26.  
  27.         while (nsetUpCounter <= 53){
  28.  
  29.             deck[nsetUpCounter] = 1;
  30.             cout << nsetUpCounter << " : " << deck[nsetUpCounter] << endl;
  31.             nsetUpCounter++;
  32.         }
  33.         cardsInDeck = 52;
  34.         cout << "all set up " << endl;
  35.     }
  36. public:
  37.     void shuffleDeck(){
  38.         cardsInDeck = 52;
  39.         int x = 0;
  40.         while (x != 52){
  41.  
  42.             deck[x] = 1;
  43.             cout << x << " : " << deck[x] << endl;
  44.             x++;
  45.         }
  46.         cout << "shuffled";
  47.     }
  48. public:
  49.     void drawCard(){
  50.         int ntestCard = 0;
  51.         int ncountCard = 1;
  52.         while (ncountCard == 1){
  53.                 if (cardsInDeck == 0){
  54.                     cout << "no more caaaaaaards" << endl;
  55.                     ncountCard = 0;
  56.                     }
  57.                 else{
  58.                     ntestCard = rand()%52;
  59.                     if (deck[ntestCard] == 1){
  60.                         ncountCard--;
  61.                         cardsInDeck--;
  62.                         cout << "you drew : " << ntestCard << " leaving " << cardsInDeck << " cards in the deck" << endl;
  63.                         deck[ntestCard] = 0;
  64.                        
  65.                        
  66.                     }
  67.  
  68.                 }
  69.             }
  70.         }
  71. public:
  72.     void readOutDeck(){
  73.         int x = 0 ;
  74.         while (x <= 51){
  75.             cout << "card " << x << " is " << deck[x] << endl;
  76.             x++;
  77.         }
  78.     }
  79. };
  80.  
  81. int main(){
  82.  
  83.    
  84.    
  85.     Deck de;
  86.     graphics ge;
  87.  
  88.     int x = 1;
  89.     int z;
  90.     int check = 1;
  91.     while (x != 0){
  92.         cin >> x;
  93.         z = x;
  94.         if (x == 111){
  95.             de.shuffleDeck();
  96.         }
  97.         else if (x == 112){
  98.             de.readOutDeck();
  99.         }
  100.         else{
  101.             while (z > 0){
  102.                         de.drawCard();
  103.                         z--;
  104.                 }
  105.         }
  106.        
  107.         cout << "ITERATION " <<check << endl;
  108.  
  109.         check++;
  110.  
  111.     }
  112.  
  113.     return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement