首页 > 学院 > 开发设计 > 正文

lx011线上赌博

2019-11-06 06:35:03
字体:
来源:转载
供稿:网友
import java.util.Random;import java.util.Scanner;public class D030602 { static int money = 1000; //全局变量 public static void main(String[] args) { System.out.PRintln("澳门首家线上赌场上线啦~"); while(money > 0){ //判断余额 System.out.println("请押大小:"); Scanner scan = new Scanner(System.in); //设定参数 String str = scan.nextLine(); //获取大小 while(!(str.equals("大") || str.equals("小"))){ //判断输入格式 System.out.println("请输入'大'或'小'"); System.out.println("请押大小:"); str = scan.nextLine(); //重新获取 } System.out.println("请输入押注金额"); int amount = scan.nextInt(); //获取金额 while(amount>money){ //判断下注金额是否超标 System.out.println("请输入正确的金额"); System.out.println("请押大小:"); amount = scan.nextInt(); //重新获取 } bet(str, amount); //调用函数 System.out.println("剩余金额:"+money); } if(money <=0) { System.out.println("余额不足,请充值"); } } public static int bet(String str,int amount) { //自定义函数 Random ran = new Random(); //定义随机数 int num1 = ran.nextInt(6)+1; int num2 = ran.nextInt(6)+1; int num3 = ran.nextInt(6)+1; int num = num1+num2+num3; if((num > 11 && str.equals("大")) ||(num <= 11 && str.equals("小"))){//判断大小 System.out.println("点数为"+num1+","+num2+","+num3); System.out.println("你赢了"+amount); money+=amount; }else{ System.out.println("点数为"+num1+","+num2+","+num3); System.out.println("你输了"+amount); money = money-amount; } return money; }}

这里写图片描述


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表