日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

发牌

發布時間:2024/2/2 60 生活家
生活随笔 收集整理的這篇文章主要介紹了 发牌 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

package com.lovo.pai;

public class TestCard {

public static void main(String[] args) {

// TODO Auto-generated method stub

Card card = new Card(4,13);

card.xiPai();

for(int i = 0; i < 4; i++){

card.faPai();

}

}

}

package com.lovo.pai;

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

public class Card {

private int playNumber;//玩家人數

private int cardNumber;//每個玩家發多少張牌

private String[] huase = {"黑桃","紅桃","梅花","方塊"};

private String[] paiValue = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};

private List<String> allCards;

public Card(int playNumber, int cardNumber){
this.playNumber = playNumber;
this.cardNumber = cardNumber;
this.allCards = new ArrayList<String>();
for(int i = 0; i < huase.length; i++){
for(int j = 0; j < paiValue.length; j++){
this.allCards.add(huase[i] + paiValue[j]);
}
}
}

public void xiPai(){
Collections.shuffle(this.allCards);
}

public void faPai(){
int allNum = this.allCards.size();//牌堆總張數
List<String> outLst = this.allCards.subList(allNum - this.cardNumber, allNum);
System.out.print("本輪發牌:");
for(String card : outLst){
System.out.print(card + " ");
}
System.out.println();
outLst.clear();
}

}

總結

以上是生活随笔為你收集整理的发牌的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。