Licensing applet for java Development, java licensing Applet

Source: Internet
Author: User

Licensing applet for java Development, java licensing Applet
Licensing Rules

In ascending order: 1-13

In ascending order: 14-26

Plum Blossom is from small to large: 27-39

The order of squares from small to large is: 40-52

King 53 King 54

Code implementation:

Package com. zsy. study; import java. io. bufferedReader; import java. io. inputStreamReader; import java. util. *; /***** @ author even my lord * game licensing */public class Cards {/***** licensing function * @ param args */private int [] [] player; // player private int [] total; // number of cards public int [] [] getPlayer () {return player;} public void setPlayer (int [] [] player) {this. player = player;} public int [] getTotal () {return total;} public vo Id setTotal (int [] total) {this. total = total ;} /*** licensing function ** @ param CardNum total number of Cards * @ param Rs count * @ param Ps number of Cards per person * @ return Cards */public static Cards PlayingCards (int Rs) {int Ps, CardNum; // number of cards per person // total number of cards if (Rs = 4) {// if the number of cards is 4, set the total number of cards to 108, and the number of cards for each person to 25 CardNum = 108; Ps = 25;} else if (Rs = 3) {// if the number is 4, set the total number of cards to 54, and the number of cards to 17 CardNum = 54; Ps = 17 ;} else {CardNum = 0; Ps = 0; System. out. println ("input error"); System. ex It (1) ;}int [] total = new int [CardNum]; // int [] [] player = new int [Rs] [Ps]; // defines the number of players and the number of cards in the array int leftNum = CardNum; // the remaining number of cards int ranNumber; // Random card random = new Random (); for (int I = 0; I <total. length; I ++) {// set the number of cards between 1 and 54, of which 1 ~ 13 indicates a color total [I] = (I + 1) % 54; //, and so on if (total [I] = 0) {// set 0 to 54 total [I] = 54 ;}} for (int I = 0; I <player [0]. length; I ++) {// randomly assigned card for (int j = 0; j <player. length; j ++) {ranNumber = random. nextInt (leftNum); // obtain the subscript randomly, player [j] [I] = total [ranNumber]; // assign the random number to the player total [ranNumber] = total [leftNum-1]; leftNum --;} Cards card = new Cards (); card. setPlayer (player); card. setTotal (total); return card;} public void print (Cards card, int rs) {int dp; for (int I = 0; I <card. getPlayer (). length; I ++) {System. out. print ("Player" + (I + 1) + "card"); for (int j = 0; j <card. getPlayer () [I]. length; j ++) {System. out. print ("" + card. getPlayer () [I] [j]);} System. out. println ();} System. out. print ("card"); if (rs = 4) {dp = 8; // set the number of cards} else {dp = 3; // set the number of cards} for (int I = 0; I <dp; I ++) {System. out. print ("" + card. getTotal () [I]);} System. out. println ();} public static void main (String [] args) throws Exception {System. out. println ("Please select the game: 1. Landlords, 2. Three dashes"); BufferedReader br = new BufferedReader (new InputStreamReader (System. in); // input statement Integer rs = Integer. valueOf (br. readLine (); Cards card = PlayingCards (rs + 2); card. print (card, rs );}}

Running result:

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.