1 import java.util.ArrayList; 2 import java.util.Collections; 3 import java.util.HashMap; 4 import java.util.Set; 5 6 import static java.util.Map.Entry; 7 public class DouDiZhu { 8 9 public static void main(String[] args) { 10 ArrayList<Integer> pook = new ArrayList<Integer>(); 11 HashMap<Integer,String> hm =new HashMap<Integer,String>(); 12 13 String[] str1 = { "♥","♣","♦","♠"}; 14 String[] str2 = {"2","A","K","Q","J","10","9","8","7","6","5","4","3"}; 15 16 int index = 2; 17 for(String s2 :str2) { 18 for(String s1 : str1) { 19 hm.put(index, s1+s2); 20 pook.add(index); 21 index++; 22 } 23 } 24 hm.put(0, "大王"); 25 pook.add(0); 26 hm.put(1, "小王"); 27 pook.add(1); 28 29 Collections.shuffle(pook); 30 31 ArrayList<Integer> player1= new ArrayList<Integer>(); 32 ArrayList<Integer> player2 = new ArrayList<Integer>(); 33 ArrayList<Integer> player3 = new ArrayList<Integer>(); 34 ArrayList<Integer> bottom = new ArrayList<Integer>(); 35 36 37 38 for (int i = 0; i < pook.size(); i++) { 39 40 if(i < 3) { 41 bottom.add(pook.get(i)); 42 }else if(i % 3 == 0) { 43 player1.add(pook.get(i)); 44 }else if(i % 3 == 1) { 45 player2.add(pook.get(i)); 46 }else if(i % 3 == 2) { 47 player3.add(pook.get(i)); 48 } 49 50 } 51 Collections.sort(player1); 52 Collections.sort(player2); 53 Collections.sort(player3); 54 Collections.sort(bottom); 55 56 57 look("赌神",hm,player1); 58 59 } 60 61 public static void look(String name,HashMap<Integer,String> ss,ArrayList<Integer> ii) { 62 System.out.print(name+":"); 63 for(Integer i : ii) { 64 System.out.print(ss.get(i)+" "); 65 } 66 System.out.println(); 67 } 68 69 70 }