public static void plays() throws IOException { Random random = new Random(); int num = random.nextInt(100); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int s = -1; int n = 0; while (num != s) { System.out.print("请输入数字:"); n++; s = Integer.parseInt(bufferedReader.readLine()); if (s > num) { System.out.println("你输入的数字太大了"); }else if (s < num){ System.out.println("你输入的数字太小了"); } } System.out.println("恭喜你猜中了,你一共猜了" + n + "次"); } public static void count() throws IOException { Properties prop = new Properties(); prop.load(new FileReader("D:\\IEAD\\data\\untitled\\count.txt")); int count = Integer.parseInt(prop.getProperty("count")); if (count > 0) { plays(); count--; prop.setProperty("count",String.valueOf(count)); prop.store(new FileWriter("D:\\IEAD\\data\\untitled\\count.txt"),null); System.out.println("你还有" + count + "次,试玩机会。"); }else { System.out.println("你的三次试用机会以用完,请到www.opt.ccc.com网站充值"); } }