In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces Java how to achieve word-guessing Mini Game, the article is very detailed, has a certain reference value, interested friends must read it!
The specific code is as follows:
Package test07;import java.util.Scanner;// guessing character game public class Guessing {/ / main method public static void main (String [] args) {Scanner scan = new Scanner (System.in); char [] chs = generate (); / / get random character array System.out.println (chs); / / cheat int count = 0; / / number of guesses while (true) {/ / self-made loop System.out.println ("guess!") String str = scan.nextLine (). ToUpperCase (); / / receive the string entered by the user and convert it to uppercase if (str.equals ("EXIT")) {/ / determine whether the string content is EXITSystem.out.println ("come again!"); break;} char [] input = str.toCharArray (); / / convert the string to a character array int [] result = check (chs,input) / / comparison: the random character array and the character array entered by the user if (result [0] = = chs.length) {/ / a pair of int score = 100 characters, deducting 10 points for each wrong guess ("Congratulations on your guess right, score:" + score); break;} else {/ / wrong count++ / / increase the number of error guesses by 1System.out.println ("the number of character pairs is" + result [1] + ", the number of position pairs is" + result [0]);} / / generate a random character array chspublic static char [] generate () {char [] chs = new char [5] / / Random character array char [] letters = {'A','B','C','D','E','F','G','Ha','I','J'C','L','M','N','O','P','Q','R','S','T','U','V' 'Xray, 'Yee,' Z'} / / Random character range array boolean [] flags = new boolean [letters.length]; / / tagged array for (int iCharacter I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.