续playPoker类
String[] color1 = {"方片", "梅花", "红桃", "黑桃"}; String[] number1 = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J","Q","K", "A"}; List<Integer> value=new ArrayList<Integer>(); for(int j=0;j<2;j++){ int valueOfC1 = 0; int valueOfC2 = 0; System.out.print(player.get(j).name+"最大手牌为:"); for(int i=0;i<number.length;i++){ if(player.get(j).shoupai.get(0).number.equals(number[i])) valueOfC1 += i*10; if(player.get(j).shoupai.get(1).number.equals(number[i])) valueOfC2 += i*10; } for(int i=0;i<color.length;i++){ if(player.get(j).shoupai.get(0).color.equals(color[i])) valueOfC1 += i; if(player.get(j).shoupai.get(1).color.equals(color[i])) valueOfC2 += i; } if(valueOfC1>valueOfC2){ System.out.println(player.get(j).shoupai.get(0).color+player.get(j).shoupai.get(0).number); value.add(valueOfC1); } else{ System.out.println(player.get(j).shoupai.get(1).color+player.get(j).shoupai.get(1).number); value.add(valueOfC2); } } if(value.get(0)>value.get(1)){ System.out.println("恭喜"+player.get(0).name+"获胜"); } else{ System.out.println("恭喜"+player.get(1).name+"获胜"); } } }
运行截图