准备牌-发牌-看牌
通过建立一个集合poker来存储一副牌;
牌分为王与其他(其他通过两个数组来构成——花色color与序号num);
通过Collections中的shuffle方法随机发牌;
package ChinesePoker;import java.util.ArrayList;
import java.util.Collections;public class Poker {public static void main(String[] args) {// TODO Auto-generated method stub//准备牌//一个合集Arralist存储一整副牌;一副牌分为王和其他;其他用两个数组来组成花色和序号ArrayList<String> poker=new ArrayList();String [] color= {"♤","♡","♣","♢",};String[] num= {"2","A","K","Q","J","10","9","8","7","6","5","4","3"};poker.add("大王");poker.add("小王");for(int i=0;i<4;i++)for(int j=0;j<13;j++) {String p=color[i]+num[j];poker.add(p);}System.out.println(poker);//发牌//建一个集合shuffle可以得到集合随机数Collections.shuffle(poker);ArrayList<String> player1=new ArrayList();ArrayList<String> player2=new ArrayList();ArrayList<String> player3=new ArrayList();ArrayList<String> hand=new ArrayList();//底牌for(int i=0;i<poker.size();i++) {if(i>=51)hand.add(poker.get(i));if(i%3==0)player1.add(poker.get(i));else if(i%3==1)player2.add(poker.get(i));else if(i%3==2)player3.add(poker.get(i));}System.out.println(player1);System.out.println(player2);System.out.println(player3);System.out.println(hand);}}