package com.imooc;
import java.util.Scanner;
//入口函数 这是一个猜拳游戏
public class caiquan {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ksjm A = new ksjm(); // 一个开始界面的类,在最下面写着
A.shuchu1();
Scanner in = new Scanner(System.in);
int person = in.nextInt();int computer = 1;
int i=0,j=0;
String Marks1 = "初始化";
String Marks2 = "初始化";
do{
if(person > 0 && person < 4){
computer = (int)(Math.random()*3)+1;
switch(person){
case 1:Marks1 = "剪刀"; break;
case 2:Marks1 = "石头"; break;
case 3:Marks1 = "布";
}
switch(computer){
case 1:Marks2 = "剪刀"; break;
case 2:Marks2 = "石头"; break;
case 3:Marks2 = "布";
}
if(person==computer){
System.out.println("||\t你出的是:"+Marks1+"\t电脑也出的是:"+Marks2+"\t||");
System.out.println("||\t\t平局~\t\t\t||");
System.out.println("||\t玩家得分:"+i+"\t电脑得分:"+j+"\t||");
}else if(person == computer + 1 || computer == person + 2){
System.out.println("||\t你出的是:"+Marks1+"!\t电脑出的是:"+Marks2+"~\t||");
System.out.println("||\t牛逼!\t嗨~~~~\t电脑胜"+",玩家负\t||");
i++;
System.out.println("||\t玩家得分:"+i+"\t电脑得分:"+j+"\t||");
}else{
System.out.println("||\t你出的是:"+Marks1+"~\t电脑出的是:"+Marks2+"!\t||");
System.out.println("||\t傻逼~\t啊哈哈哈!\t玩家胜"+",电脑负\t||");
j++;
System.out.println("||\t玩家得分:"+i+"\t电脑得分:"+j+"\t||");
}
A.shuchu2();
person = in.nextInt();
}else if(person != 0){
System.out.print("||您输入的有错误,请重新输入:");
person = in.nextInt()();
while(!(person > 0 && person < 4)){
System.out.print("||你丫有病是吧,你输入的是个啥,好好输:");
person = in.nextInt();
}
}
}while(person != 0);
System.out.println("||游戏结束!\t\t\t||");
if(i > j){
System.out.println("||最终玩家取得了胜利!\tvictory!||");
}else if(i < j){
System.out.println("||最终玩家失败了~\t~defeat~||");
}else{
System.out.println("||最终玩家和电脑旗鼓相当。\tdraw.||");
}
System.out.println("||------------------------------||");
System.out.println("||------------------------------||");
}
}//------------------------------------------------------------------
package com.imooc;
//这个类是用来设计开始界面的
public class ksjm {
public void shuchu1(){
System.out.println("||--------------------------------------||");
System.out.println("||----------------猜拳游戏----------------||");
System.out.println("||\t1、剪刀\t2、石头\t3、布\t\t||\n||\t0、退出游戏(请输入相应序号代表)\t||");
System.out.println("||--------------------------------------||");
System.out.print("||\t请出拳:");
}
public void shuchu2(){
System.out.println("||--------------------------------------||");
System.out.println("||\t1、剪刀\t2、石头\t3、布\t\t||\n||\t0、退出游戏(请输入相应序号代表)\t||");
System.out.println("||--------------------------------------||");
System.out.print("||\t请再次出拳:");
}
}
添加回答
举报
0/150
提交
取消