Java implementation Shuffle Licensing method _java

Source: Internet
Author: User
Tags shuffle

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.