标签:demo out log blog ack ring sys logs 规范
package cn.bdqn.demo; import java.util.Scanner; public class Text { String name; // 你的名字 String name02; // 电脑名字 int chuquan; int count01; // 综合 int count02; // 电脑赢 int count03; // 你赢 int ramdom; // 电脑出牌 public void showone() { Scanner input = new Scanner(System.in); System.out.println("---------欢迎进入游戏世界---------"); System.out.println("**********************"); System.out.println("******猜拳,开始*********"); System.out.println("**********************"); System.out.println("请输入你的名字"); name02 = input.next(); System.out.println("出拳规则:1.剪刀2.石头3.布"); System.out.println("请选择对方的角色(1:刘备2:孙权3:曹操)"); int juese = input.nextInt(); switch (juese) { case 1: name = "刘备"; System.out.println(name02 + "vs" + name); break; case 2: name = "孙权"; System.out.println(name02 + "vs" + name); break; case 3: name = "曹操"; System.out.println(name02 + "vs" + name); break; } } public void showtwo() { System.out.println("要开始吗?(y/n)"); Scanner input = new Scanner(System.in); String kaishi = input.next(); if (kaishi.equals("y")) { System.out.println("请出拳::1.剪刀2.石头3.布(输入对应数字)"); int chuquan = input.nextInt(); switch (chuquan) { case 1: System.out.println("你出:剪刀"); break; case 2: System.out.println("你出:石头"); break; case 3: System.out.println("你出:布"); break; default: System.out.println("请规范输入数字"); break; } int random = (int) (Math.random() * 3); // 电脑石头剪刀布 switch (random) { case 1: System.out.println(name + "出剪刀"); break; case 2: System.out.println(name + "出石头"); break; case 3: System.out.println(name + "出布"); break; } if ((chuquan == 1 && random == 1) || (chuquan == 2 && random == 2) || (chuquan == 3 && random == 3)) { System.out.println("结果:和局,真倒霉!"); count01++; } else if ((chuquan == 1 && random == 3) || (chuquan == 2 && random == 1) || (chuquan == 3 && random == 2)) { System.out.println("结果:恭喜,你赢了!"); count01++; count03++; } else { System.out.println("结果:^ _ ^,你输了,真笨"); count01++; count02++; } } else { System.out.println("准备好再来吧"); } } public void showthree() { String jixu="y"; Scanner input = new Scanner(System.in); while (jixu.equals("y")) { System.out.println("是否继续下一局(y/n)"); jixu = input.next(); showone(); showtwo(); } System.out.println("-------------------------------"); System.out.println(name02 + "vs" + name); System.out.println("对战次数\t" + count01); System.out.println("姓名\t得分"); System.out.println(name02 + "\t" + count03); System.out.println(name + "\t" + count02); } }
标签:demo out log blog ack ring sys logs 规范
原文地址:http://www.cnblogs.com/yzwss/p/7363104.html