Code:
. 1 Import of java.util.ArrayList; 2 Import java.util.Collections; . 3 . 4 public class Poker1 { . 5 public static void main (String [] args) { . 6 / * . 7 *. 1: Preparation card handling 8 * / 9 // 1.1 creating the future memory card shoe face 10 the ArrayList <String> = pokerBox new new the ArrayList <String> (); . 11 // 1.2 creating color set 12 is the ArrayList <String> Colors = new new the ArrayList <String> (); 13 is //1.3 Create a set of numbers 14 the ArrayList <String> Numbers = new new the ArrayList <String> (); 15 // 1.4 respectively assigned to color 16 colors.add ( "♥" ); . 17 colors.add ( "♦" ); 18 is colors.add ( "♠" ); . 19 colors.add ( "♣" ); 20 is // for 1.5 respectively assigned to a digital 21 is numbers.add ( "A" ); 22 is for ( int I = 2; I <= 10; I ++ ) { 23 is numbers.add ( "" + I); 24 } 25 numbers.add ( "J" ); 26 numbers.add ( "Q" ); 27 numbers.add ( "K" ); 28 // // 1.6 splicing to create a brand licensing operations 29 // come up every now and then a suit storing each digital binding to the shoe 30 for (String Color: Colors) { 31 is // Color suit every 32 // iterate a set of numbers 33 is for (String Number: numbers) { 34 is // stored in the card shoe 35 pokerBox.add (+ Color Number); 36 } 37 [ } 38 is // 1.7 king Wang 39 pokerBox.add ( "Small ☺" ); 40 pokerBox.add ( "Big ☠" ); 41 is // shuffling is not the shoe is to disrupt the index card 42 is // the Collections class tools are static 43 // shuffer method 44 / * 45 ** static void shuffle (list <?> list) 46 * use the default source of randomness to the specified list for replacement. 47 * / 48 @ 2: shuffling 49 Collections.shuffle (pokerBox); 50 // . 3 licensing 51 // 3.1 Create a set of three players to create a set of cards 52 is the ArrayList <String> = Player1 new new ArrayList<String>(); 53 ArrayList<String> player2 = new ArrayList<String>(); 54 ArrayList<String> player3 = new ArrayList<String>(); 55 ArrayList<String> dipai = new ArrayList<String>(); 56 for (int i = 0; i < pokerBox.size(); i++) { 57 String str = pokerBox.get(i); 58 if(i < 51){ 59 if(i % 3 == 0){ 60 player1.add(str); 61 } 62 else if(i % 3 == 1){ 63 player2.add(str); 64 } 65 else { 66 player3.add(str); 67 } 68 } 69 else { 70 dipai.add(str); 71 } 72 } 73 System.out.println("令狐冲:"+player1); 74 System.out.println("田伯光:"+player2); 75 System.out.println("绿竹翁:"+player3); 76 System.out.println("底牌 :"+dipai); 77 } 78 }