import java.util.Scanner;

public class startGuess {
Person jia;
Computer yi;
int count; public void initial() {
jia = new Person();
yi = new Computer();
count = 0;
} public void showout12() {
initial();
System.out.println("----------欢迎进入游戏世界-----------");
System.out.println("**********************************");
System.out.println("*** 猜拳,开始 ***");
System.out.println("**********************************");
System.out.println("出拳规则:1.剪刀 2.石头 3.布");
System.out.println("请选择对方角色(1:刘备 2:孙权 3:曹操):");
Scanner input = new Scanner(System.in);
int h = input.nextInt();
switch (h) {
case 1:
yi.name = "刘备";
break;
case 2:
yi.name = "孙权";
break;
case 3:
yi.name = "曹操";
break;
}
System.out.println("请输入你的名字:");
jia.name = input.next();
System.out.println("你选择了" + yi.name + "对战");
System.out.println("要开始吗?y:是 n:否");
String con = input.next();
while (con.equals("y")) {
int per;
int com;
if (con.equals("y")) {
per = jia.showout();
com = yi.showout11();
if ((per == 1 && com == 1) || (per == 2 && com == 2)
|| (per == 3 && com == 3)) {
System.out.println("结果:和局,真衰!");
} else if ((per == 1 && com == 3) || (per == 2 && com == 1)
|| (per == 3 && com == 2)) {
System.out.println("结果:恭喜,你赢了!");
jia.Score++;
} else {
System.out.println("结果说:^_^,你输了,真笨!");
yi.Score++;
}
count++;
} System.out.println("是否进行下一轮.y:是 n:否");
con = input.next();
}
showgg();
} public void showgg() {
System.out.println("-----------------------------");
System.out.println(jia.name + " VS " + yi.name);
System.out.println("对战次数:" + count);
System.out.println("姓名" + "\t" + "积分");
System.out.println(jia.name + "\t" + jia.Score);
System.out.println(yi.name + "\t" + yi.Score); if (jia.Score > yi.Score) {
System.out.println("甲赢了"); } else if (jia.Score < yi.Score) {
System.out.println("乙赢了"); System.out.println("-----------------------------");
}
} }
public class Person {
String name;
int Score; public int showout() {
System.out.println("请出拳:1.剪刀 2.石头 3.布(请输入相应数字):");
Scanner input = new Scanner(System.in);
int g = input.nextInt();
switch (g) {
case 1:
System.out.println("你出拳:剪刀");
break;
case 2:
System.out.println("你出拳:石头");
break;
case 3:
System.out.println("你出拳:布");
break;
}
return g;
} }
public class Computer {
String name;
int Score;
Computer out; public int showout11() {
int random = (int) (Math.random() * 3 + 1);
switch (random) {
case 1:
System.out.println("电脑出拳:剪刀");
break;
case 2:
System.out.println("电脑出拳:石头");
break;
case 3:
System.out.println("电脑出拳:布");
break;
}
return random;
} }
import java.util.*;
public class startGame {
public static void main(String[] args) {
Person a = new Person(); startGuess b = new startGuess();
b.showout12();
Computer c = new Computer(); } }

最新文章

  1. 计算机程序的思维逻辑 (46) - 剖析PriorityQueue
  2. hdu5444Elven Postman(主席树思想的应用)
  3. 消息提示插件toastr.js与Messenger组件
  4. 一段linux shell 代码涉及for循环和if esle
  5. No modifications are allowed to a locked ParameterMap
  6. 蓝桥杯 BASIC 29 高精度加法(大数)
  7. 被拒--悲剧之ORA-01017: invalid username/password; logon denied 错误
  8. ftpclient卡死问题
  9. Jackson ObjectMapper类
  10. (转)解决jdk1.8中发送邮件失败(handshake_failure)问题
  11. 关于vue的computed、filters、watch
  12. zookeeper的原理,5分钟了解zookeeper
  13. JSP页面分页显示数据
  14. Python day2 基础 2 数据类型
  15. 【转】Android7.0适配心得
  16. mybatis generator 双击创建失败
  17. 解决oracle语句中 含数字的字符串按数字排序问题
  18. 免费桌面视频录像工具OBS的简单操作介绍
  19. 类似CFS程式发布注意事项
  20. NAND flash学习所获----(Zac)

热门文章

  1. Computational Complexity of Fibonacci Sequence / 斐波那契数列的时空复杂度
  2. LeetCode练题——35. Search Insert Position
  3. 正则表达式regex回溯分析
  4. JDBC statement的常用方法
  5. 源代码管理工具(1)——SVN(1)——SVN 的使用新手指南,具体到步骤详细介绍----TortoiseSVN
  6. netty同时实现http与socket
  7. echarts做飞线图
  8. jquery中for循环
  9. 前端学习 之 JavaScript 之 JSON
  10. 设计模式课程 设计模式精讲 5-2 工厂方法coding