public class PracticePoker {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();
List<String> list3 = new ArrayList<>();
List<String> list4 = new ArrayList<>();
String[] arr = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
String[] arr1 = {"♥","♦","♠","♣"};
for (int i=0;i<arr1.length;i++) {
for (int j=0;j<arr.length;j++) {
list.add(arr1[i].concat(arr[j]));
}
}
//System.out.println(list);
list.add("大王");
list.add("小王");
Collections.shuffle(list);
Iterator<String> it = list.iterator();
while(it.hasNext()){
for (int i = 0; i < list.size(); i++) {
if (i>=list.size()-3) {
list4.add(it.next());
}else if (i%3==0) {
list1.add(it.next());
}else if(i%3==1){
list2.add(it.next());
}else{
list3.add(it.next());
}
}
}
System.out.println("玩家1"+list1);
System.out.println("玩家2"+list2);
System.out.println("玩家3"+list3);
System.out.println("底牌 "+list4);
}
} |
|