Java Development Licensing Applet

Source: Internet
Author: User

Licensing rules

Spades in order from small to large:1--

Red Peach according to from small to large in order:14-

Plum blossom according to from small to large in order:27-

The blocks follow from small to large:40-

Xiao Wang 53 King 54

Code implementation:

 PackageCom.zsy.study;ImportJava.io.BufferedReader;ImportJava.io.InputStreamReader;ImportJava.util.*;/** *  * @authoreven my yes * game Licensing*/ Public classCards {/*** Licensing function *@paramargs*/    Private int[] player;//player    Private int[] Total;//Hole number     Public int[] Getplayer () {returnplayer; }     Public voidSetplayer (int[] player) {         This. Player =player; }     Public int[] Gettotal () {returnTotal ; }     Public voidSettotal (int[] total) {         This. Total =Total ; }        /*** Licensing function *@paramcardnum Total number of cards *@paramRs Number *@paramPs Number of cards per person *@returnCards*/     Public StaticCards Playingcards (intRs) {        intPs, Cardnum;//number of cards per person//total number of cards        if(rs==4) {//If the number is 4, then the number of gross position cards is set to 108, the number of cards per person is set to 25cardnum=108; Ps=25; }Else if(rs==3) {//If the number is 4, then the number of gross position cards is set to 54, the number of cards per person is set to 17cardnum=54; Ps=17; }Else{cardnum=0; Ps=0; System.out.println ("Input Error"); System.exit (1); }        int[] total=New int[Cardnum];//        int[] player=New int[Rs] [Ps];//An array that defines the number of players and the number of cards        intLeftnum=cardnum;//the remaining number of cards        intRannumber;//randomly issued cards.Random random=NewRandom ();  for(inti = 0; i < total.length; i++) {//set the number of cards between 1--54 where 1~13 represents a suittotal[i]= (i+1)%54;//, and so forth            if(total[i]==0) {//set 0 as thetotal[i]=54; }                    }         for(inti=0;i<player[0].length;i++) {//Randomly assigned cards             for(intj=0;j<player.length;j++) {Rannumber=random.nextint (Leftnum);//randomly get subscript,Player[j][i]=total[rannumber];//Assign a random number to the playerTotal[rannumber] = total[leftnum-1]; Leftnum--; }} Cards Card=NewCards ();                Card.setplayer (player);                Card.settotal (total); returnCard; }     Public voidPrint (Cards card,intRS) {        intDP;  for(inti = 0; I < Card.getplayer (). length; i++) {System.out.print ("Player" + (i+1) + "card");  for(intj = 0; J < Card.getplayer () [I].length; J + +) {System.out.print (" "+Card.getplayer () [i][j]);        } System.out.println (); } System.out.print (Cards); if(rs==4) {DP= 8;//set the number of cards}Else{DP= 3;//set the number of cards        }         for(inti = 0; I < DP; i++) {System.out.print (" "+card.gettotal () [i]);    } System.out.println (); }     Public Static voidMain (string[] args)throwsexception{System.out.println ("Please select the game: 1, bucket landlord, 2, three dozen Ha"); BufferedReader BR=NewBufferedReader (NewInputStreamReader (system.in));//Input StatementInteger rs =integer.valueof (Br.readline ()); Cards Card=playingcards (rs+2);    Card.print (CARD,RS); }    }

Operation Result:

Java Development Licensing Applet

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.