package Hashmap;
import java.util.ArrayList;
import java.util.Collections;
public class PokeDemo {
public static void main(String[] args) {
ArrayList<String> array = new ArrayList<String>();
String[] colors = {"♦", "♥", "♠", "♣"};
String[] numbers = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
for (String color : colors) {
for (String number : numbers) {
array.add(color + number);
}
}
array.add("大王");
array.add("小王");
Collections.shuffle(array);
ArrayList<String> s1 = new ArrayList<String>();
ArrayList<String> s2 = new ArrayList<String>();
ArrayList<String> s3 = new ArrayList<String>();
ArrayList<String> s4 = new ArrayList<String>();
for (int i = 0; i < array.size(); i++) {
String poker = array.get(i);
if (i >= array.size() - 3) {
s4.add(poker);
} else if (i % 3 == 0) {
s1.add(poker);
} else if (i % 3 == 1) {
s2.add(poker);
} else if (i % 3 == 2) {
s3.add(poker);
}
}
lookpoker("小马",s1);
lookpoker("小禹",s2);
lookpoker("大哥",s3);
lookpoker("底牌",s4);
}
public static void lookpoker(String name, ArrayList<String> array) {
System.out.print(name+"的牌是");
for(String poker:array){
System.out.print(poker+" ");
}
System.out.println();
}
}
|