zoukankan      html  css  js  c++  java
  • 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();
    }
    }

  • 相关阅读:
    Hibernate实现CRUD的例子小结
    AspnetPager表格标题排序功能
    Microsoft企业库配置问题
    orm比较
    外语培训网求鉴定
    DIV随滚动条滚动而滚动
    图片切换效果展示
    转载C#委托之多播委托( 二)
    LINQ 图解
    不用ajax调用搞后台小技巧
  • 原文地址:https://www.cnblogs.com/jerry201907/p/12558448.html
Copyright © 2011-2022 走看看