The following swing interface is attached!!! Please look forward to!
Packagecom.yikuan.cn;Importjava.util.ArrayList;Importjava.util.Collections;ImportJava.util.HashMap;/*** To realize the function of simulated bucket landlord: * Combination card, shuffle, licensing, see card *@authorAdministrator **/ Public classDoudizhu {//1. The combination card, first ruled out the king of the small King 2 cards; /*Color 4 fixed value, stored in the array (array efficiency high)*/ /*13 fixed value, stored in array*/ /*iterating through an array*/ Public Static voidMain (string[] args) {/*Create Map collection, key is number, value is card*/HashMap<integer, string> pooker =NewHashmap<integer, string>(); /*Create a list collection, store numbering*/ArrayList<Integer> Pookernumber =NewArraylist<integer>(); /*defines an array of 13 points (large to small)*/string[] Numbers= {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"}; /*define 4 array of suits (click to save UTF-8)*/string[] Colors= {"?", "?", "?", ""}; /*defines an integer variable that appears as a key*/ intindex = 2;/*Let's get rid of the two kings 0,1*/ /*iterate over an array: A combination of color + points to save to a map collection*/ for(String number:numbers) { for(String color:colors) {pooker.put (index, Color+Number ); Pookernumber.add (index); Index++; } }//System.out.println (Pooker);/* Here is an unordered collection. */ /*Storage king, Xiao Wang*/Pooker.put (0, "King"); Pookernumber.add (0); Pooker.put (1, "Xiao Wang"); Pookernumber.add (1); //Shuffle, the number of cards upsetcollections.shuffle (pookernumber);//System.out.println (Pookernumber); //Licensing , the number of cards sent to the player collection, Hole setArraylist<integer> Player1 =NewArraylist<integer>(); ArrayList<Integer> Player2 =NewArraylist<integer>(); ArrayList<Integer> Player3 =NewArraylist<integer>(); ArrayList<Integer> bottom =NewArraylist<integer>(); /*the licensing is in index%3 for the collection*/ /*modulo 0--->player1.*/ /*modulo 1--->player2.*/ /*modulo 2--->player3.*/ for(intI=0;i<pookernumber.size (); i++){ /*I start from 0, if the 3 modulo, you have to do the cards first, if i<3, save to the hole to*/ if(i<3) {Bottom.add (Pookernumber.get (i)); }Else if(i%3 = = 0) {Player1.add (Pookernumber.get (i)); }Else if(i%3 = = 1) {Player2.add (Pookernumber.get (i)); }Else if(i%3 = = 2) {Player3.add (Pookernumber.get (i)); } } /*before you look at a card, sort the numbers in the player's hands.*/Collections.sort (Player1); Collections.sort (PLAYER2); Collections.sort (PLAYER3); //look at the card, the player in the hands of the number, to the map collection to find, according to the key to find the valueLook ("Wangbaoqiang", Player1,pooker); Look ("Ma Song", Player2,pooker); Look ("Song Zhe", Player3,pooker); Look (Cards, Bottom,pooker); } Private Static voidLook (String name,arraylist<integer>player, HashMap<integer, string>Pooker) {System.out.print (name+" "); /*iterate through the ArrayList collection, get the element, act as a key, and find the value in the collection map*/ for(Integer key:player) {String value=Pooker.get (key); System.out.print (Value+" "); } System.out.println (); }}
Java Bucket landlord--001 version