Understand well understood, the key is thinking
Landlords in accordance with the rules, complete reshuffle of the licensing action:
Specific rules:
1. The assembly 54 cards
2. 54 cards scramble
3. The three players involved in the game, three alternate Mopai, 17 cards per person, reserved for the last three cards.
4. Check three of their cards in the hand (according to the size sorting cards), cards
Poker hands in descending order of display: King, Wang, 2, A, K, Q, J, 10,9,8,7,6,5,4,3
com.oracle.demo01 Package; Import of java.util.ArrayList; Import java.util.Collections; Import the java.util.HashMap; Import a java.util.Map; public class Doudizhu { public static void main (String [] args) { 1 // create playing cards the Map. the Map < Integer , String > pooker = new new HashMap < Integer , String > (); // create a container where all key ArrayList < Integer > pookerNum = new new ArrayList < Integer > (); // Creating an array of colors String [] color = { "♠ ", "♣", "♥", "♦"}; // create an array of brands String [] number = { "2 ", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"}; // build brand map set into coexistence int index = 2; for (n-String: Number) { for (String C: Color) { // the data stored in the map pooker.put (index , n-C +); // save data to all containers where the key pookerNum.add (index); index ++; } } // King memory size pooker.put (0, "king"); pookerNum.add (0); pooker.put (1, "Wang"); pookerNum.add (. 1); // shuffle Collections.shuffle(pookerNum); //System.out.println(pookerNum); // licensing // Create four containers ArrayList<Integer> bottom=new ArrayList<>(); ArrayList<Integer> player1=new ArrayList<>(); ArrayList<Integer> player2=new ArrayList<>(); ArrayList<Integer> player3=new ArrayList<>(); //开始发牌 for(int i=0;i<pookerNum.size();i++){ //将前三张给底牌 if(i<3){ bottom.add (pookerNum.get (I)); } the else IF (I. 3% look ( "Nick" , player2, pooker);0 ==) { player1.add (pookerNum.get (I)); } the else IF (I. 3% ==. 1) { player2.add (pookerNum.get (I)); } the else IF (I. 3% == 2) { player3.add (pookerNum.get (I)); } } // Sort (key cards in ascending order from largest to smallest) the Collections.sort (bottom); the Collections.sort (Player1); the Collections.sort (player2); Collections.sort (player3); // read the cards (calling the method) look ( "Andy", Player1, pooker); } / / ways of looking at the cards (mass participation as player name, player's cards that is the key, all the cards of key-value pairs) look ( "Chow Yun Fat", player3, pooker); look ( "cards", bottom, pooker); look static void public (String name, ArrayList <Integer > Player, the Map < Integer , String > pooker) { // print player name System.out.print (name + ":"); // loop through all grades for (int num: Player) { of System.out.print (pooker.get (NUM) + ""); } System.out.println (); } }