Landlords case (use HashMap)

Code:

. 1  Import Classes in java.util *. ;
 2  
. 3  public  class Poker2 {
 . 4      public  static  void main (String [] args) {
 . 5          / * 
. 6           * 54 assembled cards. 1
 7           * / 
8          // 1.1 Create Map collection reservoir 
. 9          the HashMap <Integer, String> = pokerMap new new the HashMap <> ();
 10          // 1.2 set of colors to create a set of numbers 
. 11          the ArrayList <String> Colors = new new the ArrayList <> ();
 12 is          the ArrayList numbers = <String> new new the ArrayList <>();
 13          // 1.3 color and digital memory 
14          Collections.addAll (Colors, "♦", "♣", "♥", "♠" );
 15          Collections.addAll (Numbers, "A", "K", "Q", "J", "10", ". 9", ". 8", ". 7", ". 6", ". 5", ". 4", ". 3", "2" );
 16          // setting storage No variable 
17          int COUNT = 0 ;
 18          // 1.4 Creating cards to store map set 
19          pokerMap.put (COUNT, "big ☠" );
 20          pokerMap.put (COUNT ++, "small ☺" );
21         for (String color : colors) {
22             for (String number : numbers) {
23                 Color Card + = String Number;
 24                  pokerMap.put (COUNT ++ , Card);
 25              }
 26 is          }
 27          / * 
28           * 2 54 disrupt the order card
 29           * / 
30          // remove the set number 
31 is          the Set <Integer> = numberSet pokerMap.keySet ();
 32          // because to disrupt the order numbers it should first be converted into the set list 
33 is          the ArrayList <Integer> = numberList new new the ArrayList <> ();
 34 is          numberList.addAll (numberSet);
 35          // scrambled 
36         Collections.shuffle (numberList);
 37 [          / * 
38 is           *. 3 is completed by three players alternately Mopai, 17 per card, reserved for the last three cards
 39           * / 
40          // 3.1 licensing number
 41          // Create three players number set and a bottom line number set 
42 is          the ArrayList <Integer> NOP1 = new new the ArrayList <Integer> ();
 43 is          the ArrayList <Integer> NOP2 = new new the ArrayList <Integer> ();
 44 is          the ArrayList <Integer> NOP3 = new new the ArrayList <Integer> ();
 45          the ArrayList <Integer> = dipaiNo new new the ArrayList <Integer> ();
 46 is          //3.2 licensing number 
47          for ( int I = 0; I <numberList.size (); I ++ ) {
 48              // Get the number 
49              Integer Integer = numberList.get (I);
 50              IF (I> = 51 is ) {
 51 is                  dipaiNo.add (Integer);
 52 is              }
 53 is              IF (I. 3% == 0 ) {
 54 is                  noP1.add (Integer);
 55              } the else  IF (I ==. 3. 1% ) {
 56 is                  noP2.add (Integer);
 57 is              } the else {
58                  noP3.add (Integer);
 59              }
 60          }
 61 is          / * 
62 is           *. 4 see three of their cards in the hand (in the card ordered size), the cards
 63           * / 
64          // 4.1 opponents sort numbers 
65        / *   the Collections .sort (NOP1);
 66          Collections.sort (NOP2);
 67          Collections.sort (NOP3);
 68          Collections.sort (dipaiNo); * / 
69          // 4.2 were converted cards
 70          // create three players cards collection of cards and card collection surface 
71 is          the ArrayList <String> = Player1 new new the ArrayList <String> ();
 72         ArrayList<String> player2 = new ArrayList<String>();
73         ArrayList<String> player3 = new ArrayList<String>();
74         ArrayList<String> dipai = new ArrayList<String>();
75         for (Integer i : noP1) {
76             String str = pokerMap.get(i);
77             player1.add(str);
78         }
79         for (Integer i : noP2) {
80             String str = pokerMap.get(i);
81             player2.add(str);
82         }
83         for (Integer i : noP3) {
84             String str = pokerMap.get(i);
85             player3.add(str);
86         }
87         for (Integer i : dipaiNo) {
88             String str = pokerMap.get(i);
89             dipai.add(str);
90         }
91         //4.5 查看
92         System.out.println("令狐冲:" + player1);
93         System.out.println("石破天:" + player2);
94         System.out.println("鸠摩智:" + player3);
95         System.out.println ( "cards:" + dipai);
 96  
97      }
 98 }

 

Guess you like

Origin www.cnblogs.com/0error0warning/p/12528442.html