2019.12.13 array of lottery games

/**
* CaiPiaoGame.java
* com.oracle.array
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月12日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.oracle.array;
/**
* ClassName:CaiPiaoGame
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月12日 下午8:39:14
*
* @see
*/

import java.awt.Menu;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class CaiPiaoGame {
public static int[] sys=new int[6];
public static int[] client=new int[6];
public static int sysBlue;
public static int clientBlue;
public static Scanner scanner=new Scanner(System.in);
public static void main(String[] args) {
Menu();
}
public static void Menu() {
boolean flag=true;
while(flag) {
System.out.println("欢迎来购买彩票!");
System.out.println("1.购买彩票");
System.out.println("2.开奖");
System.out.println("3.退出");
System.out.println("请选择:");
int choice=scanner.nextInt();
switch (choice) {
case 1:
buylottery();
break;
case 2:
Show ();
BREAK;
Case 3:
Flag = false;
System.out.println ( "Welcome to come back next time to buy!");
BREAK;

default:
System.out.println ( "! invalid command, please re-enter");
BREAK;
}
}


}
public static void buylottery () {
Boolean = redPass to true;
System.out.println ( "Please enter the small to large (1 ~ 33) does not overlap the data: ");
for (int I = 0; I <client.length; I ++) {
System.out.println (" Please enter "+ (i + 1) + " numbers: " );
int scanner.nextInt TEMP = ();
IF (Check (TEMP, 0)) {
Client [I] = TEMP;
} the else {
System.out.println ( "data entry is not valid, for later re!") ;
Arrays.fill (Client, 0);
redPass = to false;
BREAK;
}
}
IF (redPass) {
System.out.println ( "Please enter the number of any of 1 to 16");
int blueTemp scanner.nextInt = ();
if (blueTemp> 0 &&blueTemp<17) {
clientBlue=blueTemp;
buySucc();
}
}

}
public static void buySucc() {
Arrays.sort(client);
System.out.println("购买彩票成功!");
for (int i = 0; i < client.length; i++) {
System.out.print(client[i]+"\t");
}
System.out.println("| "+clientBlue+"\t"+"\n");
System.out.println("****************************");
}
public static boolean check(int target,int mode) {
boolean result=true;
if (target<1||target>33) {
result=false;

}
if (mode==0) {
for (int i = 0; i < client.length; i++) {
if (target==client[i]) {
result=false;
break;
}
}
}else {
for (int i = 0; i < sys.length; i++) {
if (target==sys[i]) {
result=false;
break;
}
}
}
return result;
}
public static void show() {
makeRandom();
compareResult();

}
public static void makeRandom() {
boolean flag=true;
Random random=new Random();
for (int i = 0; i < sys.length; i++) {
int temp=random.nextInt(33)+1;
if (check(temp, 1)) {
sys[i]=temp;
}else {
Arrays.fill(sys, 0);
flag=false;
makeRandom();
break;
}
}
if (flag) {
sysBlue=random.nextInt(16)+1;
ranSucc ();
}
}
public static void compareResult () {
int Red = 0;
for (int I = 0; I <client.length; I ++) {
for (int J = 0; J <sys.length; J ++) {
IF (Client [I] == SYS [J]) {
red ++;
BREAK;
}
}
}
System.out.println ( "corresponds to the red zone" + red + "data");
IF (sysBlue == clientBlue) {
IF (Red> = 0 && Red <=. 4) {
System.out.println ( "winning $ 10!");
} the else IF (Red ==. 5) {
System.out.println ( "winning 200,000");
IF the else} (Red == 6) {
System.out.println ( "winning the 5 million");
} the else {
System.out.println ( "Thank you, patrons!");
}
}
}
public static void ranSucc() {
Arrays.sort(sys);
System.out.println("开奖彩票");
for (int i = 0; i < sys.length; i++) {
System.out.print(sys[i]+"\t");
}
System.out.println("| "+sysBlue+"\t"+"\n");
System.out.println("****************************");
}
}

Guess you like

Origin www.cnblogs.com/aojie/p/12036565.html