daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest May 21st, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is deck.java
  2. package cardgame;
  3.  
  4. public class Deck {
  5.     private Card [] deck;
  6.     private int currentCardPosition = 0;    
  7.    
  8.    
  9.     public Deck() {
  10.          deck = new Card [52];
  11.  
  12.         for (int i = 0; i < 52; i++) {
  13.             deck[i] = new Card (i / 13, (i % 13) + 1);
  14.         }
  15.     }
  16.    
  17.     public Card dealACard(){
  18.         if (currentCardPosition == deck.length) {
  19.             return null;
  20.         }else{
  21.             /*
  22.             Card currCard = deck[currentCardPosition];
  23.             currentCardPosition++;
  24.             return currCard;
  25.              *
  26.              */
  27.             return deck[currentCardPosition++];
  28.         }
  29.     }
  30.  
  31.     public void shuffle() {
  32.         currentCardPosition = 0;
  33.         for (int i = 0; i < 100; i++){
  34.         int pos_1 = (int) (Math.random() * deck.length);
  35.         int pos_2 = (int) (Math.random() * deck.length);
  36.  
  37.         Card tempCard = deck[pos_1];
  38.         deck[pos_1] = deck[pos_2];
  39.         deck[pos_2] = tempCard;}
  40.        
  41.     }
  42.  
  43.     public void printDetail() {
  44.         for (int i = 0; i < deck.length; i++) {
  45.             deck[i].getDetail();
  46.         }
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top