zoukankan      html  css  js  c++  java
  • 斗地主

    package cn.zhuobo.day10.Doudizhu;
    
    import java.util.ArrayList;
    import java.util.Collections;
    
    /*
    斗地主案例
    1.准备牌
    2.洗牌
    3.发配
    4.看牌
     */
    public class Doudizhu {
        public static void main(String[] args) {
            ArrayList<String> pokers = new ArrayList<>();
    
            ArrayList<String> player1 = new ArrayList<>();
            ArrayList<String> player2 = new ArrayList<>();
            ArrayList<String> player3 = new ArrayList<>();
            ArrayList<String> cardOnTable = new ArrayList<>();
    
            String[] graphs = {"♠", "♥", "♣", "♦"};
            String[] numbers = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
            for(String graph: graphs) {
                for(String number: numbers) {
                    String  poker = graph + number;
                    pokers.add(poker);
                }
            }
            pokers.add("Red Joker");
            pokers.add("Black Joker");
    
            System.out.println(pokers);
            Collections.shuffle(pokers);
            System.out.println(pokers);
    
    
    
            for (int i = 0; i < pokers.size(); i++) {
                if(i >= 51) {
                    cardOnTable.add(pokers.get(i));
                }
                else if(i % 3 == 0) {
                    player1.add(pokers.get(i));
                }
                else if(i % 3 == 1) {
                    player2.add(pokers.get(i));
                }
                else if(i % 3 == 2) {
                    player3.add(pokers.get(i));
                }
            }
    
            System.out.println("cards on table: " + cardOnTable);
            System.out.println("玩家1" + player1);
            System.out.println("玩家2" + player2);
            System.out.println("玩家3" + player3);
    
        }
    }
    
  • 相关阅读:
    三个问题
    2014-7
    2014-5
    2014-2
    2014-1
    2013-11
    mysql中对表操作----为所有列插入数据
    Redis做消息队列
    收集Nginx-access,Nginx-error日志
    .Nginx安装filebeat收集日志:
  • 原文地址:https://www.cnblogs.com/zhuobo/p/10626428.html
Copyright © 2011-2022 走看看