package homework.p08_guessgame; import java.util.Scanner; /** * @author WanJl * @version 1.0 * @title GuessGameTest * @description * @create 2026/7/22 */ public class GuessGameTest { public static void main(String[] args) { GuessGame gg=new GuessGame(100); Scanner sc=new Scanner(System.in); while (true){ System.out.print("请输入你猜的数字:"); int num = sc.nextInt(); String guess = gg.guess(num); System.out.println(guess); if (guess=="猜对了"){ break; } } System.out.println("恭喜你!一共猜了 "+gg.getAttempts()+" 次"); } }