1、switch(quan)case 1:System.out.println(name+出拳:剪刀);break;case 2:石头case 3:布return quan;第二个文件:import java.util.Scanner;public class Game int count=0;int countP=0;Person person=new Person();Computer computer=new Computer();Scanner input=new Scanner(System.in);public void initial()System.out.print(请选择你的角
2、色(1.刘备 2.孙权 3.曹操):int juese=input.nextInt();switch(juese)person.name=刘备;break;孙权曹操请选择对手角色(1.关羽 2.张飞 3.赵云):int JueSe=input.nextInt();switch(JueSe)computer.name=关羽张飞赵云public void begin()n要开始吗? (y/n)String ans=input.next();if(ans.equals(y)String answ;doint a=person.showFist();int b=computer.showfist();
3、if(a=1&b=3|a=2&b=1|a=3&b=2)System.out.println(结果:你赢了!person.score+;else if(a=1&b=1|a=2&b=2|a=3&b=3)平局,真衰!嘿嘿,等着瞧吧!countP+;else你输了!computer.score+;count+;System.out.print(n是否开始下一轮? (y/n) answ=input.next();while(answ.equals();public String calcResult()String a;if(person.scorecomputer.score)a=最终结果:恭喜恭喜!
4、else if(person.score=computer.score)打成平手,下次再和你一决高下!呵呵,你输了!笨笨,下次加油啊!return a;public void showResult()System.out.println(-tt+person.name+ VS +computer.name+n对战次数:+count+次平局:+countP+System.out.println(person.name+得:+person.score+分System.out.println(computer.name+computer.score+分nSystem.out.println(calcResult();第三个文件:public class Person public int showFist()n请出拳:1.剪刀2.石头3.布int quan=input.nextInt();case 1:System.out.println(你出拳:case 2:case 3:第四个文件:public class Test public static void main(Stringargs)Game g=new Game();-欢迎进入游戏世界-nntt*tt* 猜拳 开始 *tt*nn出拳规则:g.initial();g.begin();g.showResult();