package com.d323;
/*@author DDC
* @date 2020-3-24 13:26
* */
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class PokerII {
public static void main(String[] args) {
Map<Integer,String> pok=new HashMap<>();
ArrayList<Integer> index=new ArrayList<>();
String kinds[]={"♠","♥","♣","♦"};
String nums[]={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
int i=0;
for(String num:nums){
for(String kind:kinds){
pok.put(i,kind+num);
index.add(i++);
}
}
pok.put(i,"小王");
index.add(i++);
pok.put(i,"大王");
index.add(i++);
//System.out.println(pok);
//System.out.println(index);
Collections.shuffle(index);
//System.out.println(index);
ArrayList<Integer> p1=new ArrayList();
ArrayList<Integer> p2=new ArrayList();
ArrayList<Integer> p3=new ArrayList();
ArrayList<Integer> p0=new ArrayList();
for(int j=0;j<pok.size();j++){
int a=index.get(j);
if(j<=2){
p0.add(a);
}
if(j%3==0){
p1.add(a);
}else if(j%3==1){
p2.add(a);
}else{
p3.add(a);
}
}
Collections.sort(p0);
Collections.sort(p1);
Collections.sort(p2);
Collections.sort(p3);
showPok("Jack",pok,p1);
showPok("Lucy",pok,p2);
showPok("Rose",pok,p3);
showPok("底牌",pok,p0);
}
public static void showPok(String name,Map<Integer,String> pok,ArrayList<Integer> p){
System.out.print(name+":");
for(Integer key:p){
String value=pok.get(key);
System.out.print(value+" ");
}
System.out.println();
}
}

posted on 2020-03-24 13:25  Jerry2019717  阅读(71)  评论(0编辑  收藏  举报