This article describes the Java implementation of shuffle licensing methods. Share to everyone for your reference. as follows:
Import java.util.*;
public class Main {/** * @param args the command line arguments/static int numbersofplayers = 4;
static int numbersofhandcard = 13; public static void Main (string[] args) {//TODO code application logic here string[] player = {"Xiao Wang", "Xiao Zhang", "Xiao Zhao", "Xiao Bai"
"};
String sentence = "The Hand card is:";
String[] Huase = {"♥", "♣", "♦", "♠"};
String[] Paivalue ={"A", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K"};
List deak = new ArrayList ();
for (int i = 0;i < 4;i++) {for (int j = 0; J < 13;j++) {Deak.add (huase[i]+paivalue[j]);
} collections.shuffle (Deak);
for (int i = 0;i < numbersofplayers;i++) {System.out.print (player[i]+sentence);
System.out.println (Dealhand (Deak, Numbersofhandcard));
} public static list Dealhand (list ls,int n) {int sizepai = Ls.size ();
List Handview = ls.sublist (sizepai-n, Sizepai);
List hand = new ArrayList (Handview);
Handview.clear (); return hand;
}
}
I hope this article will help you with your Java programming.