package com.qyl.test;
import java.util.Random;
import java.util.Scanner;
import org.junit.Test;
public class Printing {
@Test
public void test2() throws Exception {
guess(10);
}
private void guess(int count) throws Exception {
System.out.println("亲:数字在0-1000之间,猜对可得7999的电脑一台");
int price = new Random().nextInt(1000);
while (count > 0) {
count--;
Scanner sc = new Scanner(System.in);
int myprice = sc.nextInt();
if (myprice>price){
System.out.println("大了,你的机会还有"+count+"次");
}else if(myprice<price){
System.out.println("小了,你的机会还有"+count+"次");
}else {
System.out.println("恭喜你猜对了,奖励你一坨狗屎");
return;
}
if (count<=0) {
System.out.println();
System.out.println("亲:你的机会用完了,请充值购买");
}
}
}
}
猜数字
最新推荐文章于 2024-03-16 15:50:03 发布