猜数字游戏
来源:互联网 发布:周星驰 锵锵三人行知乎 编辑:程序博客网 时间:2024/06/07 04:02
1、功能
登录后才可以玩游戏
2、登录Login 类
public class Login { public static void main(String[] args) { String usename = "haha"; String password = "123456"; System.out.println("登录界面"); for(int x = 0; x < 3; x++){ Scanner sc = new Scanner(System.in); System.out.println("请输入用户名:"); String name = sc.nextLine(); System.out.println("请输入密码"); String psd = sc.nextLine(); if(name.equals(usename) && psd.equals(password)){ System.out.println("登录成功,开始游戏"); GuessNumberGame.strat(); break; }else { if(x == 2){ System.out.println("你的登录次数已达到上限,被冻结了,请到我行办理解冻手续"); }else { System.out.println("登录失败"+ (2-x) + "次机会"); } } } }}
3、猜数字游戏GuessNumberGame 类
public class GuessNumberGame { private GuessNumberGame() { super(); // TODO Auto-generated constructor stub } public static void strat(){ int number = (int)(Math.random() * 100) + 1; Scanner sc = new Scanner(System.in); while (true) { System.out.println("请输入(1-100)的数字:"); int x = sc.nextInt(); if(x < number){ System.out.println("你猜的数字" + x + "小了,游戏继续"); }else if(x > number){ System.out.println("你猜的数字" + x + "大了,游戏继续"); }else { System.out.println("你猜的数字" + x + "对了,游戏结束"); break; } } }}
阅读全文
0 0
- 游戏_猜数字
- 猜数字游戏
- 猜数字游戏
- 猜数字游戏源码
- 猜数字游戏
- 猜数字游戏
- python猜数字游戏
- 猜数字游戏
- 猜数字游戏
- 猜数字游戏
- 猜数字游戏
- 猜数字游戏
- 猜数字游戏
- 关于猜数字游戏
- 猜数字游戏实现
- 猜数字游戏
- 模拟猜数字游戏
- 猜数字游戏
- 使用plsql查询数据显示为乱码解决方案
- Android 序列化和反序列化
- (转)动态规划和贪心算法的区别
- PAT 1002 A+B for Polynomials (25) Python
- Codeforces Beta Round #6 (Div. 2 Only) E. Exposition
- 猜数字游戏
- C#反射详解
- iOS
- 习题8.3
- font-size: 0;解决inline元素间的空白间隙
- zookeeper与etcd
- 欢迎使用CSDN-markdown编辑器
- 使用脚本把项目托管到Github上
- android手机安装google play服务