Java Bucket landlord Poker Poker Shuffle card Collection collection Exercises

Source: Internet
Author: User
Tags random shuffle shuffle

 PackageCom.swift.poker;Importjava.util.ArrayList;Importjava.util.Collections;/*Training Assessment Knowledge Points: The basic method of collection interface, training description: According to the rules of the landlord, to complete the shuffle licensing action.        Specific rules: The use of 54 cards in order to disrupt the sequence of three players to participate in the game, three alternating hands, 17 cards per person, the last three to stay as a hole card.    Description of the operation procedure:? Prepare the card: The card can be designed as a arraylist<string> each string is a card.    Each card is composed of two parts of the color, we can use the collection of suits and sets of numbers nested iteration to complete each card assembly. The cards are randomly sorted by the shuffle method of the Collections class. Licensing: Each person and hole cards are designed to Arraylist<string>, and the last 3 cards are stored directly in the hole cards, the remaining cards by 3 to take the mold in turn licensing. See cards: Print each collection directly */ Public classPoker { Public Static voidMain (string[] args) {ArrayList<String> huase=NewArraylist<string>(); Huase.add ("?"); Huase.add ("?"); Huase.add ("?"); Huase.add ("Square Piece"); ArrayList<String> shuzi=NewArraylist<string>(); Shuzi.add (A); Shuzi.add ("2"); Shuzi.add ("3"); Shuzi.add ("4"); Shuzi.add ("5"); Shuzi.add ("6"); Shuzi.add ("7"); Shuzi.add ("8"); Shuzi.add ("9"); Shuzi.add ("10"); Shuzi.add (J); Shuzi.add ("Q"); Shuzi.add (K); ArrayList<String> puke=NewArraylist<string>();  for(String hua:huase) { for(String Shu:shuzi) {puke.add (Hua+Shu); }} puke.add (King); Puke.add ("Xiao Wang");  for(String Str:puke) {System.out.print (str+" "); }                //Random Shufflecollections.shuffle (puke);        System.out.println ();  for(String Str:puke) {System.out.print (str+" "); }        // LicensingArraylist<string> player1=NewArraylist<string>(); ArrayList<String> player2=NewArraylist<string>(); ArrayList<String> player3=NewArraylist<string>(); ArrayList<String> dipai=NewArraylist<string>();  for(inti=0;i<54;i++) {            if(i<3) {Dipai.add (Puke.get (i)); }            Else if(i%3==0) {Player1.add (Puke.get (i)); }            Else if(i%3==1) {Player2.add (Puke.get (i)); }            Else if(i%3==2) {Player3.add (Puke.get (i)); }        }        //look at the cardsLook (player1);        Look (Player2);        Look (Player3);    Look (Dipai); }    Private Static voidLook (arraylist<string>Pai)        {System.out.println ();  for(String Str:pai) {System.out.print (str+" ");            } System.out.println (); }}

Java Bucket landlord Poker Poker Shuffle card Collection collection Exercises

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.