package pai;
、、主类
public class pai {
public static void main(String[] args) {
// TODO Auto-generated method stub
creat puke=new creat();
//创建顺序牌并输出
puke.dingyi();
xipai xi1=new xipai();
xi1.xi();
}
}
package pai;
public class creat{
String []puke=new String[52];
public void dingyi(){
int c=0;
for(int a=0;a<4;a++){
switch (a) {
case 0:{
int d=1;
for(int b=0;b<13;b++){
if(d<2){puke[c]="梅花"+"A";c++;
d++;}
else if(d<11){
puke[c]="梅花"+d;
c++;
d++;}
else if(d<=11){puke[c]="梅花"+"J";
c++;
d++;}
else if(d<=12){puke[c]="梅花"+"Q";
c++;
d++;}
else {puke[c]="梅花"+"K";
c++;
d++;}}
}
break;
case 1:{
int d=1;
for(int b=0;b<13;b++){
if(d<2){puke[c]="方片"+"A";c++;
d++;}
else if(d<11){
puke[c]="方片"+d;
c++;
d++;}
else if(d<=11){puke[c]="方片"+"J";
c++;
d++;}
else if(d<=12){puke[c]="方片"+"Q";
c++;
d++;}
else {puke[c]="方片"+"K";
c++;
d++;}}}
break;
case 2:{
int d=1;
for(int b=0;b<13;b++){
if(d<2){puke[c]="红桃"+"A";c++;
d++;}
else if(d<11){
puke[c]="红桃"+d;
c++;
d++;}
else if(d<=11){puke[c]="红桃"+"J";
c++;
d++;}
else if(d<=12){puke[c]="红桃"+"Q";
c++;
d++;}
else {puke[c]="红桃"+"K";
c++;
d++;}}}
break;
default:{
int d=1;
for(int b=0;b<13;b++){
if(d<2){puke[c]="黑桃"+"A";c++;
d++;}
else if(d<11){
puke[c]="黑桃"+d;
c++;
d++;}
else if(d<=11){puke[c]="黑桃"+"J";
c++;
d++;}
else if(d<=12){puke[c]="黑桃"+"Q";
c++;
d++;}
else {puke[c]="黑桃"+"K";
c++;
d++;}}}
break;
}
}
System.out.println("------------创建扑克牌-----------");
System.out.println("------------创建扑克牌成功!-----------");
for(int e=0;e<52;e++){
System.out.printf(puke[e]);}
}
public String[] getPuke(){
return puke;
}
}
package pai;
import java.util.Random;
public class xipai {
private Random random=new Random();
//重排序,将数组中每一个的位置与随机的位置替换。
public void xi(){
creat b=new creat();
String[]luanpai=new String[52];
luanpai=b.getPuke();
int rand=random.nextInt(52);
for(int i=0;i<52;i++){
String c;
c=luanpai[i];
luanpai[i]=luanpai[rand];
luanpai[rand]=c;
}
for(int e=0;e<52;e++){
System.out.printf(luanpai[e]);}
}
}
惊人三明治
相关分类