1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package blackjackgame;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.swing.JOptionPane;
public class deck {
//card[] carddeck= new card[52];
private card carddeck[];
int currentCard;
//*****************************************
// Constructor
//*****************************************
public deck()
{
carddeck= new card[52];
int color=0;
int value=0;
int cardcreated=0;
for(color=0;color<4;color++)
for(value=1;value<13;value++)
{
//if (value > 10)
// value = 10; // For a Jack, Queen, or King.
carddeck[cardcreated]=new card(value,color);
cardcreated++;
System.out.println(carddeck[cardcreated]);
}
}
//*****************************************
// Méthode pour tirer une carte :
//*****************************************
private List list;
public void shuffleCard(){
list=Arrays.asList(carddeck);
Collections.shuffle(list);
}
//Output Deck
public void printCards()
{
int half=list.size()/2-1;
for(int i=0,j=half;i<=half;i++,j++)
System.out.println(list.get(i).toString()+list.get(j));
}
} |