package day15;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
public class Poker {
public static ArrayList<Integer> keyNum=new ArrayList<Integer>();
public static ArrayList<Integer> player1=new ArrayList<Integer>();
public static ArrayList<Integer> player2=new ArrayList<Integer>();
public static ArrayList<Integer> player3=new ArrayList<Integer>();
public static ArrayList<Integer> dipai=new ArrayList<Integer>();
public static ArrayList<String> number=new ArrayList<String>();
public static ArrayList<String> color=new ArrayList<String>();
public static HashMap<Integer, String> newPoker=new HashMap<Integer,String>();
public static void main(String[] args) {
for (int i =1; i <=54; i++) {
keyNum.add(i);
}
Collections.shuffle(keyNum);
for (int i = 0; i <keyNum.size(); i++) {
if(i>=51){
dipai.add(keyNum.get(i));
}
else{
if (i%3==0) {
player1.add(keyNum.get(i));
}
if (i%3==1) {
player2.add(keyNum.get(i));
}
if (i%3==2) {
player3.add(keyNum.get(i));
}
}
}
System.out.println(player1);
System.out.println(player2);
System.out.println(player3);
System.out.println(dipai);
for (int i = 3; i <=10; i++) {
number.add(i+"");
}
Collections.addAll(number,"J","Q","K","A","2");
color.add("♠");
color.add("♥");
color.add("♦");
color.add("♣");
int index=0;
for (int i = 0; i < number.size(); i++) {
String thisNum = number.get(i);
for (int j = 0; j < color.size(); j++) {
String thisColor = color.get(j);
String thisPoker=thisNum+thisColor;
newPoker.put(index++, thisPoker);
}
}
newPoker.put(index++, "小☺");
newPoker.put(index++, "大☻");
System.out.println("=====================");
System.out.println(newPoker);
Collections.sort(player1);
Collections.sort(player2);
Collections.sort(player3);
Collections.sort(dipai);
show(player1,newPoker);
show(player2,newPoker);
show(player3,newPoker);
show(dipai,newPoker);
}
private static void show(ArrayList<Integer> list,HashMap<Integer, String> map) {
for(Integer key:list){
System.out.print(map.get(key-1)+" ");
}
System.out.println();
}
}
|
|