上次写了一个通过random生成随机数来猜数字的小游戏,这次我经过修改,增加了记录已猜数字次数和限制猜数字次数困难模式的功能.
话不多说直接看代码:
import java.util.Random;
import java.util.Scanner;
public class GuessNumber {
public static void main(String[] args) {
Random r = new Random();
Scanner sc = new Scanner(System.in);
int num = r.nextInt(100) + 1;
int count = 0;
System.out.println("请输入你要选择的模式:");
System.out.println("1.简单模式(直到猜中为止)");
System