• Fri. Oct 7th, 2022

    Write a guessing game with java

    ByGoodBoy

    Sep 23, 2022
    5 thoughts on “Write a guessing game with java”
    1. Importjava.util.Scanner; PublicClassGame {privatescannerScan = Newscanner (System.in); PrivatestringRule [], "Scissors", "Stone", "cloth"}; "孙权","曹操"};privateComputercomputer;privateUseruser;privateint;privateGame(){=0;}publicstaticvoidmain(String[]args){Gamegame=newGame();game.start();}publicvoidstart(){computer= newcomputer (); System.out.println ("-welcome to the game world-"); system.out.println ("************************************ );System.out.println("**猜拳,开始**");System.out.println("********************");System .out.println (); System.out.println ("Boxing Rules: 1. Scissors 2. Stone 3. cloth"); System.out.print ("Please select the role (1: Liu Bei 2. Sun Quan 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. Cao Cao 3. ) "); Intuserrole = scan.nextint (); if (userrole> = 1

    2. I wrote a source code for guessing the game before, but not as wonderful as you thought. You just gave you 5 points to modify it yourself, it should be very simple. Give more points, I can help you modify it.
      import java.util.scanner;
      import java.util.random;
      PUBLIC class caipan
      {
      final into jian = 0; ;
      final into = 2;

      public static void main (string [] args)
      {
      string yn = "y";
      whilele (yn.equals ("y")
      {
      scanner scanner = new scanner (System.in);
      system.out.println ("Welcome to play the game. 1, 2: 0 indicates scissors, 1 indicates stones, 2 indicates cloth ");
      int a = scanner.nextint ();

      random rd = new rate (); r r r r r r r
      int b = rd.nextint (3);

      switch (b)
      {
      case 0:
      {
      system.out.println ( "The system is scissors");
      switch (a)
      {
      case 0: system.out.println ("flat"); break;
      case 1: systemm .out.println ("Win"); Break;
      Case 2: System.out.println ("Load"); Break; n case 1:
      {
      System.out.println ("The system is stones");
      switch (a) r {
      case 0: systemm .out.println ("losing"); BREA k;
      case 1: system.out.println ("flat"); break;
      case 2: system.out.println ("win"); break;
      } r r r r r r r r
      }
      break;
      case 2:
      {
      system.out.println ("The system comes out of cloth");
      switch (a)
      {
      case 0: system.out.println ("win"); break;
      case 1: system.out.println ("losing"); break; .out.println ("flat"); break;
      }
      }
      }
      scanner ynn = new scanner (System.in);
      system.out. Println ("continues? Please enter Y, otherwise enter n. ");
      yn = ynn.next ();
      }
      }
      }

    3. importjava.util.Scanner;abstractclassComputer{abstractvoidplayGame();}publicclassGameextendsComputer{publicstaticvoidmain(String[]args){newGame().playGame();}staticScannersc=newScanner(System.in);staticString[]games={"猜拳游戏"}; StaticString [] root = {" Liu Bei "," Sun Quan "," Cao Cao "}; Staticfinalstring [] mora = {" Stone "," Scissors "," cloth "}; staticstring = 0; @Overridevoidplaygame () {();} publicvoid () {system.out.println ("-welcome to the game world-"); ********** "); System.out.println (" "** guess boxing, start **"); System.out.println ("*************************************************************************************************************************************************************************************************************************, ****** "); System.out.println (" Boxing Rules: 1. Scissors 2. Stone 3. cloth "); Stringstartmsg =" Please select the character: "; for (inti = 0; I u003Croot. length; i ) {startmsg = (i 1) "." Roles [i];} System.out.println (StartMSG); stringinput = sc.nextline (); = root [(input)]; System. out.println ("Do you want to start? (y/n"); StringISSTART = sc.nextline (); if ("y" .equals (isstart)) {GameStart ();} else {System.Println (" End "); sc.close (); Return;} int (stringInput) {intindex = 0; switch (input) {case" 1 ": index = 0; break; case" 2 ": index = 1; break; case "3": index = 2; break; default: break;} re turnIndex;} voidgamestart () {playcount ; system.out.println ("Please punch: 1. Stone 2. Scissors 3. cloth"); Stringinput = sc.nextline (); TRY {intINDEX = Integer.vartOF (ins. ; System.out.println ("You punch:" Mora [Index-]); int = (int) math.ceil (math.random ()*3); : " Mora [-1]); System.out.println ( " vs computer "); System.out.println (" Battle times: " playcount); if (index ==) {system.out.println ("Result: He Bureau, really decline! Hey, wait and see! ");} Elseif (== 0

    4. I wrote a source code for guessing the game before, but not as wonderful as you thought. You just gave you 5 points to modify it yourself, it should be very simple. Give more points, I can help you modify it.
      import java.util.scanner;
      import java.util.random;
      PUBLIC class caipan
      {
      final into jian = 0; ;
      final into = 2;

      public static void main (string [] args)
      {
      string yn = "y";
      whilele (yn.equals ("y")
      {
      scanner scanner = new scanner (System.in);
      system.out.println ("Welcome to play the game. 1, 2: 0 indicates scissors, 1 indicates stones, 2 indicates cloth ");
      int a = scanner.nextint ();

      random rd = new rate (); r r r r r r r
      int b = rd.nextint (3);

      switch (b)
      {
      case 0:
      {
      system.out.println ( "The system is scissors");
      switch (a)
      {
      case 0: system.out.println ("flat"); break;
      case 1: systemm .out.println ("Win"); Break;
      Case 2: System.out.println ("Load"); Break; n case 1:
      {
      System.out.println ("The system is stones");
      switch (a) r {
      case 0: systemm .out.println ("losing"); BREA k;
      case 1: system.out.println ("flat"); break;
      case 2: system.out.println ("win"); break;
      } r r r r r r r r
      }
      break;
      case 2:
      {
      system.out.println ("The system comes out of cloth");
      switch (a)
      {
      case 0: system.out.println ("win"); break;
      case 1: system.out.println ("losing"); break; .out.println ("flat"); break;
      }
      }
      }
      scanner ynn = new scanner (System.in);
      system.out. Println ("Do you continue to see if you continue to see Y, otherwise enter n. ");
      yn = ynn.next ();
      }
      }
      }

    Leave a Reply