1、炸金花简版比大小。
2、任意随机三个数字。比较大小。
3、暂时不考虑花色,对子,三张
4、但需考虑连牌顺子情况。
public class StringTest01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Person p1=new Person();
Person p2=new Person();
Poke[] pc1=new Poke[3];
Poke[] pc2=new Poke[3];
for(int i=0;i<pc1.length;i++){
pc1[i].key=Poke.pokecard[(int)(Math.random()*14)];
pc2[i].key=Poke.pokecard[(int)(Math.random()*14)];
}
p1.poke=pc1;
p2.poke=pc2;
for(int i=0;i<3;i++){
Poke.zhuanhua(p1.poke[i].key);
Poke.zhuanhua(p2.poke[i].key);
}
int m1,m2;
m1=Poke.findMax(p1);
m2=Poke.findMax(p1);
if(p1.poke[m1].value>p2.poke[m2].value){
System.out.println("玩家一赢了");
}else{
System.out.println("玩家二赢了");
}
}
}
class Person{
Poke[] poke;
boolean isShun;
}
class Poke{
String key;
int value;
static String[] pokecard={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
public static int findMax(Person p1){
int max=0;
for(int i=1;i<3;i++){
if(p1.poke[max].value<p1.poke[i].value){
max=i;
}
}
return max;
}
public void panduan(Person p1,Person p2){
}
public static int zhuanhua(String s){
switch(s){
case "A":
return 14;
case "2":
return 2;
case "3":
return 3;
case "4":
return 4;
case "5":
return 5;
case "6":
return 6;
case "7":
return 7;
case "8":
return 8;
case "9":
return 9;
case "10":
return 10;
case "J":
return 11;
case "Q":
return 12;
case "K":
return 13;
}
return 0;
}
}