斗地主进阶版
package cn.cast.day4;
import java.util.*;
public class DouDiZhu {
public static void main(String[] args) {
HashMap<Integer, String> poker = new HashMap<>();
ArrayList<Integer> pokerIndex = new ArrayList<>();
List<String> colors = List.of("♠", "♥", "♣", "♦");
List<String> numbers = List.of("2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3");
int Index = 0;
poker.put(Index, "大王");
poker.put(++Index, "小王");
Index++;
for (int i = 0; i < 54; i++) {
pokerIndex.add(i);
}
for (int i = 0; i < numbers.size(); i++) {
for (int j = 0; j < colors.size(); j++) {
String str = numbers.get(i);
str.concat(colors.get(j));
poker.put(Index, str);
Index++;
}
}
Collections.shuffle(pokerIndex);
HashSet<Integer> player1 = new HashSet<>();
HashSet<Integer> player2 = new HashSet<>();
HashSet<Integer> player3 = new HashSet<>();
HashSet<Integer> dipai = new HashSet<>();
for (int i = 0; i < pokerIndex.size(); i++) {
if (i>51){
dipai.add(pokerIndex.get(i));
}else if (i%3==1){
player1.add(pokerIndex.get(i));
}else if(i%3==2){
player2.add(pokerIndex.get(i));
}else if (i%3==0){
player3.add(pokerIndex.get(i));
}
}
System.out.println("dipai = " + dipai);
System.out.println("player1 = " + player1);
System.out.println("player2 = " + player2);
System.out.println("player3 = " + player3);
}
}