标签:port rgs 个人 otto imp public new void bottom
package com.sxt.other; /* * 字符串数组+集合ArrayList * 模拟扑克发牌 */ import java.util.ArrayList; import java.util.Collections; import java.util.List; public class PokerCard { public static void main(String[] args) { String[] color = {"?","?","?","?"}; String[] num = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; //集合存储每一张牌 List<String> pokerList = new ArrayList<>(); for(int i=0; i<color.length; i++){ for(int j=0; j<num.length; j++){ pokerList.add(color[i]+num[j]);//字符串 数字和花色组合 } } pokerList.add("小王"); pokerList.add("大王"); System.out.println(pokerList); System.out.println("扑克牌的张数:"+pokerList.size()); //洗牌 Collections.shuffle(pokerList); System.out.println(pokerList); //发牌 3个人每人17张牌 还有3张底牌 List<String> client1 = new ArrayList<>(); List<String> client2 = new ArrayList<>(); List<String> client3 = new ArrayList<>(); List<String> bottomCard = new ArrayList<>(); for(int i=0; i<pokerList.size(); i++){ if(i<51){ if(i%3==0){ client1.add(pokerList.get(i)); }else if(i%3==1){ client2.add(pokerList.get(i)); }else{ client3.add(pokerList.get(i)); } }else{ bottomCard.add(pokerList.get(i)); } } System.out.println("玩家1的牌:"+client1); System.out.println("玩家2的牌:"+client2); System.out.println("玩家3的牌:"+client3); System.out.println("底牌:"+bottomCard); } }
标签:port rgs 个人 otto imp public new void bottom
原文地址:http://www.cnblogs.com/qingfengzhuimeng/p/6758733.html