//不好意思瞎扯了,悲剧啊,你写个函数就可以了,你看看
import java.util.Scanner;
public class Teste{
public String result(int num){
if(num == 1){
return "剪刀";
}
if(num == 2){
return "石头";
}
if(num == 3){
return "布";
}
return "未知";
}
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("————猜拳游戏————");
System.out.println("请出拳:(1、剪刀 2、石头 3、布)");
int people=in.nextInt();
int computer=(int)(Math.random()*3)+1;
//
String Marks="拳头";//这是给人做标记的;
//
String Marks2="拳头";//这是给电脑做标记的;
//
switch(people){
//
case 1:
//
Marks="剪刀";
//
break;
//
case 2:
//
Marks="石头";
//
break;
//
case 3:
//
Marks="布";
//
break;
//
}
//
switch(computer){
//
case 1:
//
Marks2="剪刀";
//
break;
//
case 2:
//
Marks2="石头";
//
break;
//
case 3:
//
Marks2="布";
//
break;
//
}
Teste test = new Teste();
System.out.println(computer);
int result = 0;
if(Math.abs(people-computer)== 2){
result = -(people-computer);
}else{
result = people-computer;
}
if(result == 0){
System.out.println("平局你出的的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}
if(result > 0){
System.out.println("你赢了你出的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}
if(result < 0){
System.out.println("你输了你出的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}
if(people==computer){
System.out.println("平局你出的的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}else if(people==1&&computer==2||people==2&&computer==3||people==3&&computer==1){
System.out.println("你输了你出的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}else{
System.out.println("你赢了你出的是:"+test.result(people)+"电脑出的是:"+test.result(computer));
}
}
}