用Java写一个简单的猜拳游戏

用Java写一个简单的猜拳游戏

不多说直接上代码:

import java.util.*;
public class Yancey20{
	public static void main(String[]args){
	int score=0;//记录得分情况
	int count=0;//记录出拳的次数
	System.out.println("欢迎来到猜拳游戏,请输入您的昵称:");
	Scanner in=new Scanner(System.in);
	String name=in.next();
	while(true){
	Random ran=new Random();
    int rang=ran.nextInt(3)+1;//产生0--2的随机数	
	String duishou="";
	if(rang==1){duishou="石头";}
	else if(rang==2){duishou="布";}
	else{duishou="剪刀";}
	Scanner input=new Scanner(System.in);
	System.out.println();
	System.out.println("请选择下列编号出拳:");
	System.out.println("1:石头 2:布 3:剪刀 0:结束本轮游戏");
	//System.out.println(duishou);
	int chuquan=input.nextInt();	
	if(chuquan==0) break;
	if(chuquan>3||chuquan<0){
		System.out.println("出拳错误");		
	}
	else if(chuquan==1){
		System.out.pr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值