package com.company;
import java.util.Scanner;
public class caiquan {
Stringname ="石头";
Stringbu ="布";
Stringdao ="剪刀";
Scannerscanner =new Scanner(System.in);
public static void main(String[] args) {
caiquan rr =new caiquan();
rr.ww();
}
public void ww(){
System.out.println("你叫什么?");
String name =scanner.next();
System.out.println(name+"欢迎你!");
boolean flag =true;
do {
System.out.println("欢迎进入猜拳游戏!");
System.out.println("1.开始");
System.out.println("2.结束");
System.out.println("请选择:");
int cc =scanner.nextByte();
switch (cc){
case 1:
System.out.println("猜拳vs");
gg();
break;
case 2:
System.out.println("谢谢使用!");
flag =false;
break;
}
}while (flag);
}
public void gg(){
System.out.println("请在下方选择一个对决人物");
System.out.println("1.唐僧");
System.out.println("2.孙悟空");
System.out.println("3.猪八戒");
System.out.println("请选择:");
int zhu =scanner.nextByte();
switch (zhu){
case 1:
System.out.println("vs开始");
System.out.println("在下方下方选择你的出拳");
System.out.println("1.石头");
System.out.println("2.剪刀");
System.out.println("3.布");
System.out.println("请选择:");
int ii =scanner.nextByte();
switch (ii){
case 1:
System.out.println("你出了石头!");
// System.out.println("vs开始");
// System.out.println("在下方下方选择你的出拳");
// System.out.println("1.石头");
// System.out.println("2.剪刀");
// System.out.println("3.布");
// System.out.println("请选择:");
int i =1;
int j =3;
int p = (int) i + (int) (Math.random() * (j - i));
System.out.println("唐僧出了:"+p);
// System.out.println(p);
// int hh = scanner.nextByte();
switch (p){
case 1:
System.out.println("石头");
System.out.println("平局");
System.out.println("唐僧:我佛慈悲!");
break;
case 2:
System.out.println("剪刀");
System.out.println("你赢了");
System.out.println("唐僧:悟空救我!");
break;
case 3:
System.out.println("布");
System.out.println("你输了");
System.out.println("唐僧:八十一难我又过了一劫,西天我来了.");
break;
}
}
}
}
}
此上面只有一种猜拳方案,其他的请对照着来