Abstract: I amGuangdong Institute of petrochemical technologyOneFreshman, BecauseMobile DevelopmentI am very interested, so I learned the basics of Java in my free time during the summer vacation.
Today is me.20 years oldOfBirthdayIt's not easy to think about it. After 20 years, I didn't give myself any gifts. So today I spent a little time writing a Java game as my birthday gift!
When I went to college, I liked my blog garden. I learned a lot of valuable knowledge and took this opportunity to thank the blog garden!
I always haveDreamIn the hope that the blog will be published on the homepage one day.ArticleI really hope this gift can be posted onBlog homepage, I know, BenProgramVery rough. Ask the editors of the blog Park to give points as appropriate!
AgainThank you for choosing blog!
The following is the program source code:
1 /* 2 * Title: the first birthday gift for your life! 3 * Author: igeneral 4 * Date: December 1, lunar July 6 5 * Describe: igeneral gave him a birthday present for his 20th years! 6 ** Today is the anniversary of the full moon in Java. It is also your birthday ~~ This day is very important! -- I entered the ranks of the second child-I grew up and became small! 7 ** The first birthday present in your life is quite satisfying despite its low grade. After all, there are a lot worth celebrating! 8 * Here, igeneral would like to take this opportunity to thank my mom and dad for raising me, educating my friends and teachers, and accompanying my friends, classmates, and senior sisters! 9 * Program function: Simulate the "scissors and stone cloth competition", and finally determine the total winner by counting the number of players and the number of winning or losing players on the computer! 10 */ 11 Package Second_day; 12 Import Java. util. vendor; 13 Import Java. util. Random; 14 Public Class JSB { 15 Public Static Void Main (string [] ARGs ){ 16 System. Out. println ("... · the beginning of the game ···········" ); 17 Boolean Bool = True ; 18 Required SC = New Using (system. In ); 19 Int [] TJ = New Int [100]; 20 // System. Out. println (TJ. Length); the number of inputs is 100. 21 Int A, B, c, d; // A is used to record the player's choice, B is used to record the computer's choice, and D is used to record the results of each game. 22 String S = "" ; 23 Random ran = New Random (); 24 For (Int I = 0; bool; I ++ ){ 25 System. Out. println ("0 represents scissors \ N1 represents stone \ N2 represents cloth" ); 26 System. Out. println ("select :" ); 27 A = SC. nextint (); 28 B = ran. nextint (3 ); 29 If (B = 0 ){ 30 S = "Scissors" ; 31 } Else { 32 If (B = 1 ){ 33 S = "stone" ; 34 } 35 Else { 36 S = "cloth" ; 37 } 38 } 39 C = A-B; // Determine whether to win or lose by comparing the difference of the number! 40 Switch (C ){ 41 Case 1 : 42 Case -2: system. Out. println ("congratulations, system output" + S + ", you won this game! "); D = 1; Break ; 43 Case 0: system. Out. println ("okay, the system goes out" + S + ", draw! "); D = 2; Break ; 44 Default : System. Out. println ("sorry, the system goes out" + S + ". You lose this game! "); D = 3 ; 45 } 46 TJ [I] = D; // Count the result of winning or losing to the array. 47 System. Out. println ("enter" 0 "to continue." 1 "to exit! \ N '''''''''''''''''''''''''''''''''" ); 48 If (SC. nextint () = 1 ){ 49 Bool = False ; 50 } 51 } 52 A = 0; 53 B = 0 ; 54 C = 0 ; 55 For ( Int I = 0; I <TJ. length; I ++ ){ 56 If (TJ [I]! = 0 ){ 57 C ++ ; 58 } 59 If (TJ [I] = 1 ){ 60 A ++ ; 61 } Else If (TJ [I] = 2 ){ 62 B ++ ; 63 } 64 } 65 System. out. println ("Number of matches:" + C + "\ n wins:" + A + "\ n draws: "+ B +" \ n ··············! " ); 66 If (A> C- A ){ 67 System. Out. println ("Win-it's worth it. But don't forget, your dream-even if you know that is almost impossible, that is the final victory! " ); 68 } Else If (A = c- A ){ 69 System. Out. println ("flat -- all the world's wins and losses are so small in front of death! "Don't be limited by dogma. Listen to your own voice and do what you want to do ." " ); 70 } Else { 71 System. Out. println (", that's temporary! -- Steve left Apple and set up next and Pixar when he was thirty years old! " ); 72 } 73 } 74 } /* Output'' 75 · The start of the game with scissors and stone headers ··········· 76 0 represents scissors 77 1 represents stone 78 2 stands for cloth 79 Select: 80 0 81 Sorry, the system is out of stone. You have lost this game! 82 Enter "0" to continue. "1" to exit! 83 ''''''''''''''''''''''''''''''''' 84 0 85 0 represents scissors 86 1 represents stone 87 2 stands for cloth 88 Select: 89 1 90 Sorry, the system went out of stock. You lost this game! 91 Enter "0" to continue. "1" to exit! 92 ''''''''''''''''''''''''''''''''' 93 0 94 0 represents scissors 95 1 represents stone 96 2 stands for cloth 97 Select: 98 2 99 Congratulations! The system is out of the rock. You won this game! 100 Enter "0" to continue. "1" to exit! 101 ''''''''''''''''''''''''''''''''' 102 1 103 Number of competitions: 3 104 Victory: 1 105 Draw: 0 106 ··············! 107 It's only temporary! -- Steve left Apple and set up next and Pixar when he was thirty years old! 108 */