模拟谁最厉害小游戏
来源:互联网 发布:淘宝一键复制有违规吗 编辑:程序博客网 时间:2024/04/30 14:54
import java.util.*;
import java.io.*;
class Game {
Scanner scanner = new Scanner(System.in);
LinkedList save = new LinkedList();
int coptNum = 0, humanNum = 0;
Game() {
for(int i = 0; i < 20 + (Math.random() * 10 / 3); i++) {
save.add("b");
}
save.add("a");
}
public int getMachinNum() {
int compN = (int) (Math.random() * 10 / 3);
return compN;
}
public int getHumenNum() {
int humenN = new Scanner(System.in).nextInt();
return humenN;
}
}
public class stickGame {
static int n = 0;
public static void main(String args[]){
try{
Game game = new Game();
System.out.println("你要拿几个火柴?(1~3根):");
while(!(stickGame.n == 1 && stickGame.n == 2)) {
int n = game.getHumenNum();
for(int i = 0; i <= n; i++) {
String string1 = (String) game.save.get(i);
if(string1 == "a"){
System.out.println("电脑赢");
break;
}
game.save.remove(0);
}
System.out.println("电脑拿了" + game.getMachinNum() + "个火柴");
for(int j = 0; j < game.getMachinNum(); j++) {
String string2 = (String)game.save.get(j);
if(string2 == "a") {
stickGame.n = 2;
System.out.println("玩家赢");
break;
}
game.save.get(0);
}
System.out.println("你要拿几个火柴?");
}
}catch(Exception e) {
System.out.println("游戏结束!");
}
}
}
import java.io.*;
class Game {
Scanner scanner = new Scanner(System.in);
LinkedList save = new LinkedList();
int coptNum = 0, humanNum = 0;
Game() {
for(int i = 0; i < 20 + (Math.random() * 10 / 3); i++) {
save.add("b");
}
save.add("a");
}
public int getMachinNum() {
int compN = (int) (Math.random() * 10 / 3);
return compN;
}
public int getHumenNum() {
int humenN = new Scanner(System.in).nextInt();
return humenN;
}
}
public class stickGame {
static int n = 0;
public static void main(String args[]){
try{
Game game = new Game();
System.out.println("你要拿几个火柴?(1~3根):");
while(!(stickGame.n == 1 && stickGame.n == 2)) {
int n = game.getHumenNum();
for(int i = 0; i <= n; i++) {
String string1 = (String) game.save.get(i);
if(string1 == "a"){
System.out.println("电脑赢");
break;
}
game.save.remove(0);
}
System.out.println("电脑拿了" + game.getMachinNum() + "个火柴");
for(int j = 0; j < game.getMachinNum(); j++) {
String string2 = (String)game.save.get(j);
if(string2 == "a") {
stickGame.n = 2;
System.out.println("玩家赢");
break;
}
game.save.get(0);
}
System.out.println("你要拿几个火柴?");
}
}catch(Exception e) {
System.out.println("游戏结束!");
}
}
}
- 模拟谁最厉害小游戏
- 最厉害的人
- 有史以来最厉害的售货员
- 世界上最厉害的售货员
- 【t062】最厉害的机器人
- 老虎狮子谁厉害
- 上半年最厉害的10大病毒
- 世界最厉害的搏击术
- 最厉害的催费电话!!!!!!
- 最厉害的催费电话
- 国内RIA界最厉害的人
- 地球上最厉害的字体:Helvetica
- c语言模拟扫雷小游戏
- 什么功夫最厉害?最厉害的武功一招能把人怎么样?
- 坐火车时最厉害的逃票技巧
- 西游记里最厉害的法宝——手机
- 你的键盘哪些键磨损得最厉害
- 微软最厉害的角色是--架构师!
- 循环的跳出和继续
- asp页面中插入媒体播放器。。
- Android利用tcpdump抓包
- android 动画1
- STM8L151x IWDG总结
- 模拟谁最厉害小游戏
- PHP模板Smarty 初级学习 重点是:配置项的说明
- android 动画2
- Eclipse(Windowns XP)下搭建Android开发环境——简介
- ubuntu下安装飞信
- ADO.NET Entity Framework 之“无法加载指定的元数据资源。”
- concepts阅读总结6——视图和索引
- [我的Linux技术支持生涯] 网卡无法激活问题的排查
- C#调用Oracle存储过程的方法