- import java.util.*;
- public class caiquan{
- public static void main(String[] args){
- Random A=new Random();
- int B=(A.nextInt(3))+1;//int C=(B+1);
- String B1=Integer.toString(B);
- loop:
- while(true){
- System.out.println("-*-*-*-*-定锤*游戏-*-*-*-*-");
- System.out.println("请猜拳:1.石头,2.剪刀,3.布 4.退出");
- Scanner S=new Scanner(System.in);
- String SS=S.next();
- String Marks1="出拳";//标记;
- switch(SS){
- case "1":
- Marks1="石头";
- break;
- case "2":
- Marks1="剪刀";
- break;
- case "3":
- Marks1="布";
- break;
- case "4":
- System.out.println("GAME OVER");
- break loop;
- }
- String Marks2="出拳";//标记;
- switch(B1){
- case "1":
- Marks2="石头";
- break;
- case "2":
- Marks2="剪刀";
- break;
- case "3":
- Marks2="布";
- }
- if(SS.equals(B1)){
- System.out.println("你出的是"+Marks1+",电脑出的是"+Marks2+",平局");
- }
- else if(SS.equals("1")&&B1.equals("2")||SS.equals("2")&&B1.equals("3")||SS.equals("3")&&B1.equals("1")){
- System.out.println("恭喜你赢了~~");
- }
- else if(SS.equals("1")&&B1.equals("3")||SS.equals("2")&&B1.equals("1")||SS.equals("3")&&B1.equals("2")){
- System.out.println("你出的是"+Marks1+",电脑出的是"+Marks2+",不好意思你输了");
- }
- else{
- System.out.println("输入错误,请重新输入");
- }
- }
- }
- }
复制代码 |
|