54 simulated landlords and 54 landlords

Source: Internet
Author: User

54 simulated landlords and 54 landlords
54 cards simulate landlords

Package demo; import java. util. random;/*** 54 card shuffling and issuing cards **/public class Puker {public static void main (String [] args) {Random random = new Random (); // initialize the array String [] puker = {"♠A ","♠2 ","♠3 ","♠4 ","♠5 ","♠6 ","♠7 ","♠8 ","♠9 ","♠10 ","♠J ","♠Q ","♠K ","♥A ","♥2 ","♥3 ","♥4 ","♥5 ","♥6 ","♥7 ","♥8 ","♥9 ","♥10 ","♥J ","♥Q ","♥K ","♣A ","♣2 ","♣3 ","♣4 ","♣5 ","♣6 ","♣7 ","♣8 ","♣9 ","♣10 ","♣J ","♣Q ","♣K ","♦A ","♦2 ","♦3 ","♦4 ","♦5 ","♦6 ","♦7 ","♦8 ","♦9 ","♦10 ","♦J ","♦Q ","♦K "," "," "}; // declare the base card String [] p1 = new String [17] for three players. string [] p2 = new String [17]; String [] p3 = new String [17]; String [] bluff = new String [3]; // simulate shuffling for 1000 times (int I = 0; I <1000; I ++) {int r1 = random. nextInt (puker. length); int r2 = random. nextInt (puker. length); String tmp = puker [r1]; puker [r1] = puker [r2]; puker [r2] = tmp;} // transaction int index = 0; for (int I = 0; I <puker. length;) {if (I <3) {// retain three cards first bluff [I] = puker [I ++];} else {// licensed to three players p1 [index] = puker [I ++]; p2 [index] = puker [I ++]; p3 [index] = puker [I ++]; index ++ ;}} System. out. println ("base card:"); for (int I = 0; I <bluff. length; I ++) {System. out. print (bluff [I] + "");} System. out. println ("\ n Player 1 card:"); for (int I = 0; I <p1.length; I ++) {System. out. print (p1 [I] + "");} System. out. println ("\ n PLAYER 2 is:"); for (int I = 0; I <p2.length; I ++) {System. out. print (p2 [I] + "");} System. out. println ("\ n Player 3 is:"); for (int I = 0; I <p3.length; I ++) {System. out. print (p3 [I] + "");}}}

 

Related Article

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.