该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.util.Random;
class card
{
public String face;
public String suit;
public card(String f,String s)
{this.face=f;
this.suit=s;
}
public String toString()
{ String x=suit+": "+face+" ";
return x;
}
}
class DeckOfCards
{ card zj[];
public DeckOfCards()
{
zj=new card[52];
String number[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
String huase[]={"红桃","方块","梅花","黑桃"};
for(int i=0;i<52;i++) //对card的每个对象初始化
{
//zj[i].suit=number[i%13];
//zj[i].face=huase[i/4];
zj[i]=new card(number[i%13],huase[i/13]);
// System.out.print(zj[i]);
}
}
public void shuffle() //洗牌
{ //zj=new card[52];
Random r=new Random();
for (int i=0;i<52;i++)
{
int j=r.nextInt(52); //52个随机数
card temp=zj[j]; //对zj[j]与zj[i]进行交换
zj[j]=zj[i];
zj[i]=temp;