Interpersonal Scissors Reference answers:

Source: Internet
Author: User

(for reference only, have any questions, can contact Bo main QQ2838509529 directly)

Scissors class:

  

 Public classDemo01 {Scanner input=NewScanner (System.inch); intWj//the player punches    intDn//a computer punch .    intD=0;//Number of inputs    intb=0;//Number of inputsString A;//whether to start    intx; intT//PvP TimesString N;//Computer nameString name;//player Name    intAa//number of players won    intbb//number of computer wins     Public voidSun () {System. out. println ("\t\t** Scissors, start **\n\n"); System. out. println ("Punch Rules: 1. Fist 2. Stone 3. Cloth"); System. out. Print ("Please select the opponent role 1. Meichuan 2. Kawauchi cool 3. Nude Brother:"); DN=Input.nextint (); if(dn==1) {System. out. println ("you choose PVP * Meichuan * General"); }Else if(dn==2) {System. out. println ("you choose PvP * Plum Kawauchi Cool * General"); }Else if(dn==3) {System. out. println ("you choose to battle * Naked Brother * General"); } System. out. println (); }     Public voidAun () {System. out. Print ("do you want to start? (y)"); A=Input.next (); System. out. Print ("Please enter your name:"); String name=Input.next ();  Do{T++; if(A.equals ("y") ) {System. out. Print ("please punch: 1. Scissors 2. Stone 3. Cloth"); WJ=Input.nextint (); if(wj==1) {System. out. println (name+"out Scissors"); }Else if(wj==2) {System. out. println (name+"out of Stone"); }Else if(wj==3) {System. out. println (name+"out cloth"); } x=(int) (Math.random () *Ten%3+1);//generates a random number within the 1~10        if(dn==1) {n="* Meichuan Cool son * General"; }Else if(dn==2) {n="* Plum Kawauchi Cool * General"; }Else{n="* Naked Brother * General"; }        if(x==1) {System. out. println (n+"out Scissors"); }Else if(x==2) {System. out. println (n+"out of Stone"); }Else if(x==3) {System. out. println (n+"out cloth"); }        }Else{System. out. println ("End Game"); }        if(wj==x) {System. out. println ("Draw!!! "); }Else if((wj==1&&x==3)|| (wj==2&&x==1)|| (wj==3&&x==2) ) {System. out. println (name+"win!!! "); AA++; }Else{System. out. println (n+"win!!! "); BB++; } System. out. println (); System. out. Print ("do you want to start? (y)"); A=Input.next (); } while(A.equals ("y")); System. out. println (); System. out. println ("__________________________________"); System. out. println (name+"VS"+N); System. out. println ("PvP times are"+t); System. out. println ("PVP Results:"); if(aa>BB) {System. out. println (name+"won the"); }Else if(aa==BB) {System. out. println ("Draw"); }Else if(aa<b) {System. out. println (n+"won the"); } System. out. println ("__________________________________"); }

Test class:

  

 Public Static void Main (string[] args) {        //  TODO auto-generated method stub        Demo01 sum=New Demo01 ();        Sum.sun ();        Sum.aun ();    }

Hint: For reference only original: Meichuan cool son

Interpersonal Scissors Reference answers:

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.