猜数字
来源:互联网 发布:vscode 插件推荐 编辑:程序博客网 时间:2024/06/09 17:18
import java.util.Scanner;
import com.sxt.oop.school;
/**
* @author Rory
* @category 猜数 1到100内猜数
*/
public class Caishu {
int a = (int) (Math.random() * 100);
int s;
public void Cai() {
System.out.println("请输入你猜的数字");
Scanner sc = new Scanner(System.in);
s = sc.nextInt();
//return s;
}
public void Check() {
boolean flag = true;
do {
if (s == a) {
System.out.println("恭喜你,猜对了");
System.exit(0);
}
if (s > a) {
System.out.println("大了");
} else {
System.out.println("小了");
}
Cai();
} while (flag);
}
import com.sxt.oop.school;
/**
* @author Rory
* @category 猜数 1到100内猜数
*/
public class Caishu {
int a = (int) (Math.random() * 100);
int s;
public void Cai() {
System.out.println("请输入你猜的数字");
Scanner sc = new Scanner(System.in);
s = sc.nextInt();
//return s;
}
public void Check() {
boolean flag = true;
do {
if (s == a) {
System.out.println("恭喜你,猜对了");
System.exit(0);
}
if (s > a) {
System.out.println("大了");
} else {
System.out.println("小了");
}
Cai();
} while (flag);
}
}
/**
* @author Administrator
* @category 猜数测试
*/
public class CaishuTest {
public static void main(String[] args) {
Caishu shu=new Caishu();
shu.Cai();
shu.Check();
}
}
0 0
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 【转载】8天入门wpf—— 第七天 画刷
- 程序员生存定律--成长路上常见的坑
- 《大话数据结构》
- 【转载】8天入门wpf—— 第八天 最后的补充
- Android 之热门标签设计
- 猜数字
- SDWebImage的缓存机制
- 数据库索引的作用和优点缺点
- 【HDU】-4324-Triangle LOVE(拓扑,环)
- 381. Insert Delete GetRandom O(1) - Duplicates allowed
- 《大话数据结构》
- NOIP2007【矩阵取数游戏】
- Pixhawk与树莓派3的串口通信
- (转载总结)SVD 及其在推荐系统中的应用