作者:手机用户2502905891 | 来源:互联网 | 2023-08-19 16:09
原标题:猜字小游戏(JAVA)
2021.04.19
题目描述:
思路:
语法基础:StringBuilder 类似列表,可以更改元素。
package Practice;
public class tt {
public static void main(String[] args) {
String str = "banana";
System.out.println(str.indexOf文章来源站点https://www.yii666.com/('z'));
System.out.println(str.indexOf('a', 2));
StringBuilder words = new StringBuilder();
for (int i = 0; i < 5; i++)
words.append('*');
System.out.println(words.length());
System.out.println(words.indexOf("a"));
System.out.println(words.indexOf("*", 1));
words.setCharAt(3, 'a');
System.out.println(words);
}
}
代码:
package Practice;
import java.util.Scanner;
public class Guess {
public static String words[] = {"banana", "telecommunication", "programming", "bupt"};
public static boolean[] guwww.yii666.comessed = new boolean[words.length];
public static int num_guessed = 0;
public static char keep;
public static void main(String[] args) {
效果图:
全部猜完:
中途退出:
来源于:猜字小游戏(JAVA)