Package Com.loaderman.test;import Java.util.arraylist;import Java.util.collections;public class Test {/** * * A: Case Demo * Simulation Bucket landlord shuffle and licensing, cards are not sorted * * Analysis: * 1, buy a pair of poker, in fact, is to create a collection of objects, the cards stored in * 2, Shuffle * 3, Licensing * 4, see the card */public static void Main (string[] args) {/ /1, buy a pair of poker, in fact, you create a collection object, the cards are stored string[] num = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K"} string[] color = {"Red peach", "spades", "Square piece", "Plum"}; arraylist<string> poker = new arraylist<> ();//stitching the suit and number for (string s1:color) {s2:num (string poker.add) (s 1.concat (S2)); Concat Connect two strings}}poker.add ("Xiao Wang");p Oker.add ("King"),//2, Shuffle collections.shuffle (poker);//3, licensing arraylist<string > Gaojin = new arraylist<> (); arraylist<string> Longwu = new arraylist<> (); arraylist<string> me = new arraylist<> (); arraylist<string> Dipai = new arraylist<> (); for (int i = 0; i < poker.size (); i++) {if (I >= poker.size () -3) {Dipai.add (Poker.get (i));//store three cards in the hole card collection} else if (i% 3 = = 0) {Gaojin.add (Poker.get (i));} else if(i% 3 = = 1) {Longwu.add (Poker.get (i));} else {Me.add (Poker.get (i));}} 4, see card System.out.println (Gaojin); System.out.println (LONGWU); System.out.println (Me); System.out.println (Dipai);}}
Code implementation: Simulated bucket landlord shuffle and licensing, cards are not sorted