斗地主出局java代码,用java代码模拟了斗地主发牌

package itcast.pojo;

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

import java.util.Random;

/**

* 分析:扑克类中有洗牌的功能和发牌的功能,属性是牌,一幅牌有54张包括大王小王 属性:54张扑克 功能:洗牌 发牌 装牌

*

* @author Administrator

*

*/

public class Poker{

private String[] pokerNum = { "A", "2", "3", "4", "5", "6", "7", "8", "9",

"10", "J", "Q", "K" };

private String[] pokerColor = { "黑桃", "红桃", "梅花", "方块" };

public List newPoker() {

List list = new ArrayList();

for (int x = 0; x < pokerColor.length; x++) {

for (int y = 0; y < pokerNum.length; y++) {

list.add(pokerColor[x].concat(pokerNum[y]));

}

}

list.add("大王");

list.add("小王");

return list;

}

public List washPoker(List list) {

Collections.shuffle(list);

return list;

}

public void playPoker(List l1, List l2, List l3,

List poker) {

for (int x = 0; x < poker.size(); x++) {

if (x < poker.size() - 3) {

l1.add(poker.get(x));

l2.add(poker.get(++x));

l3.add(poker.get(++x));

} else {

System.out.print(poker.get(x) + " ");

}

}

System.out.println();

System.out.println("玩家1 : "+l1);

System.out.println("玩家2 : "+l2);

System.out.println("玩家3 : "+l3);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值