//玩家类
import java.util.Scanner;
public class 玩家{
String name;
Scanner input = new Scanner(System.in);
public int 出拳(){
System.out.print(this.name+"请出拳:(0.石头1.剪刀2.布)");
int a=input.nextInt();
return a;
}
}
//电脑类
import java.util.Random;
public class 电脑{
public int 出拳(){
Random rand=new Random();
int b=rand.nextInt(3);
int temp=rand.nextInt(10);
int c;
if(temp==0||temp==1){//让人只有20%赢的可能
if(r==0){
c=1;
}else if(r==1){
c=2;
}else{
c=0;
}
}else{
if(r==0){
c=2;
}else if(r==1){
c=0;
}else{
c=1;
}
}
if(b==0){
System.out.println("电脑出的是石头");
}else if(b==1){
System.out.println("电脑出的是剪刀");
}else if(b==2){
System.out.println("电脑出的是布");
}
return b;
}
}
//裁判类
public class 裁判{
public void 裁决(int a,int b){
int c=a-b;
if(c==0){
System.out.println("平手");
}else if(c==-1){
System.out.println("人胜");
}else{
System.out.println("电脑胜");
}
}
}
//测试类
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
String d;
do{
System.out.println("游戏开始!");
玩家 a=new 玩家();
a.name="小马";
电脑 b=new 电脑();
裁判 c=new 裁判();
int aN=a.出拳();
int bN=b.出拳();
c.裁决(aN,bN);
System.out.print("还要玩吗?");
d=input.next();
}while(d.equals("y"));
System.out.println("游戏结束");
}
}