vue项目接口域名动态的获取方法
206
2023-07-30
Java实现洗牌发牌的方法
本文实例讲述了java实现洗牌发牌的方法。分享给大家供大家参考。具体如下:
import java.util.*;
public class Main {
/**
* @param args the command line arguments
*/
static int numbersOfPlayers = 4;
static int numbersOfHandCard = 13;
public static void main(String[] args) {
// TODO code application logic here
String[] player = {"小王","小张","小赵","小白"};
String sentence = "的手牌是:";
String[] huase = {"♥","♣","♦","♠"};
String[] paiValue ={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
List deak = new ArrayLpRGJxAcyYVist();
for(int i = 0;i < 4;i++){
for(int j = 0; j < 13;j++)
{
deak.add(huase[i]+paiValue[j]);
}
}
Collections.shuffle(deak);
for(int i = 0;i < numbersOfPlayers;i++){
System.out.print(player[i]+sentence);
System.out.println(dealHand(deak, numbersOfHandCard));
}
}
public static List dealHand(List Ls,int n){
int sizePai = Ls.size();
List handView = Ls.subList(sizePai - n, sizePai);
List hahttp://nd = new ArrayList(handView);
handView.clear();
return hand;
}
}
希望本文所述对大家的java程序设计有所帮助。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~