public String getPais() {
//这一步就是洗牌
int index = (int)(Math.random()*number);
number--;
String p = pais[index];
for(int i = index;i<number;i++) {
pais[i] = pais[i+1];
}
return p;
}
public void getWish() {
//这一步就是买牌
String hua = "黑红方梅";
for(int i = 0;i<4;i++) {
for(int j = 1 ; j<=13;j++) {
switch(j) {
case 1 :
pais[index++] = hua.charAt(i)+"A";
break;
case 11 :
pais[index++] = hua.charAt(i)+"J";
break;
case 12 :
pais[index++] = hua.charAt(i)+"Q";
break;
case 13 :
pais[index++] = hua.charAt(i)+"K";
break;
default :
pais[index++] = hua.charAt(i)+""+j;
break;
}
}
}
pais[52] = "小王";
pais[53] = "大王";
}
总感觉代码很多,然后有些许的还是很懵懂
|
|