|
@@ -0,0 +1,179 @@
|
|
|
|
+package com.lc.day04.exer02;
|
|
|
|
+
|
|
|
|
+import java.util.Scanner;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * ClassName: Test03
|
|
|
|
+ *
|
|
|
|
+ * @Author 爱扣钉-陈晨
|
|
|
|
+ * @Create 2023/11/12 17:02
|
|
|
|
+ * @Version 1.0
|
|
|
|
+ */
|
|
|
|
+public class Test03 {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {int money;boolean play=true;
|
|
|
|
+ Scanner scanner=new Scanner(System.in);int getin;int bei;int _final;int ori;
|
|
|
|
+
|
|
|
|
+ System.out.println("你想要多少钱作为起始资金");
|
|
|
|
+ money=scanner.nextInt();
|
|
|
|
+
|
|
|
|
+ while(true) {
|
|
|
|
+ int get=0; ori=money;
|
|
|
|
+ System.out.println("输入你的下注以及基础倍率");
|
|
|
|
+ System.out.println("下注为");
|
|
|
|
+ int in = scanner.nextInt();
|
|
|
|
+ System.out.println("你还剩下"+(money-in)+"元");
|
|
|
|
+ while(true) {
|
|
|
|
+ System.out.println("你要的基础倍率为(基础倍率每加1,入场费加五十,入场费的基础为100)");
|
|
|
|
+ bei = scanner.nextInt();
|
|
|
|
+ getin = 50 * bei;
|
|
|
|
+ System.out.println("入场费为"+getin+"确定吗??(true or false)");
|
|
|
|
+ boolean toopen=scanner.nextBoolean();
|
|
|
|
+ if(toopen==false){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ System.out.println("输入完毕");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ money=money-in-getin;
|
|
|
|
+ if(money<0)
|
|
|
|
+ {
|
|
|
|
+ System.out.println("你的钱不够,不该来这里");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ System.out.println("你还剩下"+money+"元");
|
|
|
|
+ int[] input_1 = new int[5];
|
|
|
|
+ int input;
|
|
|
|
+ boolean judge = true;
|
|
|
|
+ System.out.println("输入五个红色球(1~36)");
|
|
|
|
+ while (true)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
|
+ {
|
|
|
|
+ input_1[i] = scanner.nextInt();
|
|
|
|
+ for(int j=0;j<i;j++)
|
|
|
|
+ {
|
|
|
|
+ if(input_1[i]==input_1[j])
|
|
|
|
+ {
|
|
|
|
+ judge=false;
|
|
|
|
+ System.out.println("数据输入有误,请输入不重复的数据");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(input_1[i]>36||input_1[i]<=0)
|
|
|
|
+ {
|
|
|
|
+ judge=false;
|
|
|
|
+ System.out.println("数据输入错误,重新输入(1~36)");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else if(input_1[i]>=0&&input_1[i]<=36)
|
|
|
|
+ {
|
|
|
|
+ if(4-i!=0)
|
|
|
|
+ System.out.println("还需输入" + (4 - i) + "个");
|
|
|
|
+ else if(4-i==0)
|
|
|
|
+ System.out.println("输入完毕");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(judge==false)
|
|
|
|
+ {
|
|
|
|
+ judge=true;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(judge==true)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ while(true){
|
|
|
|
+ System.out.println("输入蓝球");
|
|
|
|
+ input = scanner.nextInt();
|
|
|
|
+ if(input>7) {
|
|
|
|
+ System.out.println("重新输入");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ break;}
|
|
|
|
+ int[] output = new int[5];
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
+ output[i] = (int) (Math.random() * 100) % 35 + 1;
|
|
|
|
+ int r = output[i];
|
|
|
|
+ for (int j = 0; j < i; j++)
|
|
|
|
+ if (r == output[j]) {
|
|
|
|
+ i--;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int output_1 = (int) (Math.random() * 10) % 7 + 1;
|
|
|
|
+ int red = 0, blue = 0;
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
+ for (int j = 0; j < 5; j++) {
|
|
|
|
+ if (input_1[i] == output[j])
|
|
|
|
+ red++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (input == output_1)
|
|
|
|
+ blue++;
|
|
|
|
+ System.out.println("开奖啦!!!");
|
|
|
|
+
|
|
|
|
+ System.out.println("红球即将出现!!!");
|
|
|
|
+
|
|
|
|
+ for(int i=0;i<5;i++)
|
|
|
|
+ { System.out.print("第"+(i+1)+"个红球是---");
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ System.out.println(output[i]+" ");
|
|
|
|
+ }
|
|
|
|
+ System.out.println("你猜的是");
|
|
|
|
+ for(int i=0;i<5;i++) {
|
|
|
|
+
|
|
|
|
+ System.out.print(input_1[i]);
|
|
|
|
+ }
|
|
|
|
+ System.out.println("蓝球即将揭晓!!");try {
|
|
|
|
+ Thread.sleep(2000);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ if(blue==1)
|
|
|
|
+ System.out.println(output_1+"你猜对啦!!!!");
|
|
|
|
+ else if(blue==0)
|
|
|
|
+ System.out.println("很遗憾,蓝球是"+output_1+"而你猜的是"+input);
|
|
|
|
+ System.out.println("你猜对了"+"red"+"个红球");
|
|
|
|
+ if (red >= 2) {
|
|
|
|
+ for (int i = 0; i < red; i++)
|
|
|
|
+ bei *= 200;
|
|
|
|
+ if (blue == 1)
|
|
|
|
+ bei *= 5000;
|
|
|
|
+ get = in * bei;
|
|
|
|
+ money = money+ get;
|
|
|
|
+
|
|
|
|
+ } else if(red<2)
|
|
|
|
+ ;
|
|
|
|
+ if(ori-money<0)
|
|
|
|
+ System.out.println("你挣了"+(money-ori)+"元");
|
|
|
|
+ else if(ori-money>0)
|
|
|
|
+ System.out.println("你亏了"+(ori-money)+"元");
|
|
|
|
+ System.out.println("你现在还有" + money + "元");
|
|
|
|
+ if(money<0)
|
|
|
|
+ break;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ System.out.println("继续玩吗??(true/false)");
|
|
|
|
+ play = scanner.nextBoolean();
|
|
|
|
+ if (play == false)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ System.out.println("游戏结束,你最终有"+money+"元");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|