• To be a master II.


     

    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();
    }
    }

  • 相关阅读:
    360天擎安装上之后,手机开热点之后就没有办法连接
    Redis基本数据类型--Hash(哈希)
    Redis基本数据类型--Set
    redis的五种基本数据类型之List
    Redis的五种基本数据类型 String
    Android应用程序的安装位置
    Java中long和Long有什么区别(转)
    Logcat打印调试信息
    Java GUI图形界面开发工具
    CSDN精选Android开发博客
  • 原文地址:https://www.cnblogs.com/jerry201907/p/12558448.html
Copyright © 2020-2023  润新知