锤子剪刀布.doc锤子剪刀布.doc
import java.util.Scanner;public class Person
{
int score;
Scanner input=new Scanner(System.in);
public int show()
{
System.out.println("\n请出拳:1.剪刀2.石请3.布\n");
int quan=input.nextInt();
switch(quan)
{
case 1:System.out.println("你出拳:剪刀");
break;
case 2:Sys...
锤子剪刀布.doc
import java.util.Scanner;public class Person
{
int score;
Scanner input=new Scanner(System.in);
public int show()
{
System.out.println("\n请出拳:1.剪刀2.石请3.布\n");
int quan=input.nextInt();
switch(quan)
{
case 1:System.out.println("你出拳:剪刀");
break;
case 2:System.out.println("你出拳:石");请
break;
case 3:System.out.println("你出拳:布");
break;
}
return quan;
}
}
public class Computer {
int score;
public int show(){
int quan;
quan=(int)(Math.random()*3+1);
//if(quan<=2){
//quan=1;
//}else if(quan<=5){
//quan=2;
//}else{
//quan=3;
//}
switch(quan){
case 1:System.out.println("请请出拳:剪刀");break;
case 2:System.out.println("请请请出拳:石");break;
case 3:System.out.println("请请出拳:布");break;
}
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 begin()
{
System.out.print("\n要始游,请请请请请请 (y/n)");String ans=input.next();ans = ans.toLowerCase();if(ans.equals("y"))
{
String answ;
do{
int a=person.show();
int b=computer.show();
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)
{
System.out.println("平局:嘿嘿,等着瞧吧!");
countP++;
}
else
{
System.out.println("你了:请请请");
computer.score++;
}
count++;
System.out.print("\n是否始下一请请请请请? (y/n)");
answ=input.next();
}while(answ.equals("y"));}
}
public String calcResult(){String result;
if(person.score>computer.score){
result="最果:恭喜恭喜:你了:请请请请请请请请请请请请请";
}
else if(person.score==computer.score)
{
result="最果:打成平手,下次再和你一决高下请请请请请请请请请请请请请请请请请请!";}
else
{
result="最果:你了:笨蛋,下次加油啊:请请请请请请请请请请请请请请请请请";}
return result;
}
public void showResult()
{
System.out.println("---------------------------------------------------");
System.out.println("\t\t"+ "你 VS "+"请请\n");
System.out.println("请请次数:"+count+"次");
System.out.println("平局:"+countP+"次");
System.out.println("你得:"+person.score+"分");
System.out.println("请请得:"+computer.score+"分\n");
System.out.println(calcResult());
System.out.println("---------------------------------------------------");
}
}
public class Teste
{
public static void main(String[]args)
{
Game game=new Game();
System.out.println("\n-----------------请请请请请请请迎入游世界--------------------\n\n");
System.out.println("\t\t*********************");
System.out.println("\t\t** 请 子剪刀布**");
System.out.println("\t\t*********************\n\n");
System.out.println("出拳:请请请1.剪刀2.石请3.布");
game.begin();
game.showResult();
}
}
本文档为【锤子剪刀布.doc】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。