1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| package com.tipdm.Demo03;
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List;
public class demo1 { public static void main(String[] args) { HashMap<Integer, String> poker = new HashMap<>(); ArrayList<Integer> pokerIndex = new ArrayList<>(); int index = 0; pokerIndex.add(index); poker.put(index, "大王"); index++; pokerIndex.add(index); poker.put(index, "小王"); index++; String[] hs = {"♠", "♥", "♣", "♦"}; String[] dx = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"}; for (int i = 0; i < dx.length; i++) { for (int i1 = 0; i1 < hs.length; i1++) { pokerIndex.add(index); poker.put(index, hs[i1]+dx[i]); index++; } }
Collections.shuffle(pokerIndex); ArrayList<Integer> poker1 = new ArrayList<>(); ArrayList<Integer> poker2 = new ArrayList<>(); ArrayList<Integer> poker3 = new ArrayList<>(); ArrayList<Integer> dp = new ArrayList<>(); System.out.println(pokerIndex); for (int i = 0; i < pokerIndex.size(); i++) { if(i >= 51){ dp.add(pokerIndex.get(i)); }else if(i % 3 == 0){ poker1.add(pokerIndex.get(i)); }else if(i % 3 == 1){ poker2.add(pokerIndex.get(i)); }else if(i % 3 == 2){ poker3.add(pokerIndex.get(i)); } } Collections.sort(poker1); Collections.sort(poker2); Collections.sort(poker3);
System.out.println(poker1); System.out.println(poker2); System.out.println(poker3); System.out.println(dp); index2color("刘德华", poker, poker1); index2color("周润发", poker, poker2); index2color("陈小刀", poker, poker3); index2color("底牌", poker, dp); }
private static void index2color(String name, HashMap<Integer, String> map, ArrayList<Integer> list) { System.out.print(name+":["); for (Integer key : list) { String value = map.get(key); System.out.print(value + ","); } System.out.println("]"); }
}
|