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<String> newPoker() {
List<String> list = new ArrayList<String>();
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<String> washPoker(List<String> list) {
Collections.shuffle(list);
return list;
}
public void playPoker(List<String> l1, List<String> l2, List<String> l3,
List<String> 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);
}
}
|