首先,我有一个带有此代码的名为 card 的类
public class Card
{
private int value;
private String suit;
// private int value;
//private String rank;
public Card (int v, String s)
{
    value=v;
suit=s;
}
public int random()
{
    int randomNum = ((int)(Math.random() * 100) % 13 +1);
    return randomNum;
}
public void displayCard()
{
    System.out.println(value + " of " + suit);
}
}
然后我有一个名为deck的类,上面有这段代码
import java.util.*;
public class Deck 
{
public ArrayList<Card> card;
private ArrayList<String> suits;
private ArrayList<Card> hand;
public Deck()// time to build a deck
{
    card=new ArrayList<>();
    suits=new ArrayList<>();
    suits.add("Hearts");
    suits.add("Spades");
    suits.add("Clubs");
    suits.add("Diamonds");
    for (int y=2; y<15; y++)
        {
            card.add(new Card(y,suits.get(0)));
        }
    for (int y=2; y<15; y++)
        {
            card.add(new Card((y),suits.get(1)));
        }
    for (int y=2; y<15; y++)
        {
            card.add(new Card((y),suits.get(2)));
        }
    for (int y=2; y<15; y++)
        {
            card.add(new Card((y),suits.get(3)));
        }
}//end of public deck
public ArrayList deal()// deal method
{
    hand=new ArrayList<>();
    for(int x = 0; x < 5; ++x)//build 5 card hand
        {
        hand.add(card.get(x));
        System.out.println(card.get(x));
         }
    return hand;
}//end of public void deal
}// end of public class deck
然后我有主要的
import java.util.ArrayList;
import java.util.*;
public class gamePlay 
    {
        private static gamePlay player1;
        public Deck fullDeck;
        private ArrayList<Card> yourHand;
    public gamePlay()
    {
        fullDeck=new Deck();
        System.out.println("Your poker hand is a");
        yourHand = fullDeck.deal();
        //System.out.println(yourHand);
    }
public static void main(String[] args) 
{
player1 = new gamePlay();        
}
}
它正在打印出一些疯狂的东西,用于手中卡片的价值和花色