java 10.18.2

package com.lovo;

import java.util.Scanner;
	
public class Test03 {
	
	/**
	 * 摇一个骰子
	 * @return
	 */
	public static int roll(){
		return (int) (Math.random()*6+1);
	}
	
	
	public static void main(String[] args) {
		int firstPoint,currentPoint;
		Scanner sc = new Scanner(System.in);
		int total=10000;
		for(;total>0;){
			firstPoint = currentPoint = roll()+roll();
			System.out.printf("玩家总资金:%d\n",total);
			System.out.println("<---请下注--->");
			int m = sc.nextInt();
			if(m<=total){
				boolean goon = false;
				switch(currentPoint){
				case 7:
				case 11:
					System.out.printf("玩家%d点,玩家胜!!\n",currentPoint);
					System.out.printf("余额:%d\n",total+=m);
					break;
				case 2:
				case 3:
				case 12:
					System.out.printf("玩家%d点,庄家胜!!\n",currentPoint);
					System.out.printf("余额:%d\n",total-=m);
					break;
					default:
						System.out.printf("玩家掷出%d点\n",currentPoint);
						goon = true;
				}
				while(goon){
					currentPoint = roll()+roll();
					System.out.printf("玩家掷出%d点\n",currentPoint);
					if(currentPoint == 7){
						System.out.print("庄家胜!");
						System.out.printf("余额:%d\n",total-=m);
						goon = false;
					}else if(currentPoint==firstPoint){
						System.out.print("玩家胜!");
						System.out.printf("余额:%d\n",total+=m);
						goon = false;
					}
				}
				if(total <=0){
					System.out.printf("余额不足!!\nGAME OVER!");
					break;
				}
			}else{
				System.out.println("余额不足!!");
				continue;
			}
		}
		sc.close();
	}
}

项目突然跑不起来报这个错 Exception in monitor thread while connecting to server 10.18.21.79:27117 com.mongodb.MongoSocketReadException: Exception receiving message at com.mongodb.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:536) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:421) at com.mongodb.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:290) at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255) at com.mongodb.connection.CommandHelper.sendAndReceive(CommandHelper.java:84) at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:34) at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:91) at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:51) at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:127) at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114) at java.lang.Thread.run(Thread.java:748) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at com.mongodb.connection.SocketStream.read(SocketStream.java:84) at com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:547) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:418)
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值