package com.source_file;
import java.util.Scanner;
/*
* Filename: LuckyDraw.java
* Dates: Thursday, September 7, 2017
* Description: Lucky draw System
* Author: NotCare
* */
public class LuckyDraw {
// Declare global variables
static int g_nVIPid; // Membership card number
static String g_szUser; // User name
static String g_szCipher; // Password
static String g_szGoon; // Continue to input
// Main method
public static void main(String[] args) {
int nNum; // Inputting options
Scanner input = new Scanner(System.in);
System.out.println(" **-Welcome to the lottery system-**");
System.out.println("╔═════════════════╗");
System.out.println("║ ① .Registration ║");
System.out.println("║ ②.Landfall ║");
System.out.println("║ ③.raffle ║");
System.out.println("╚═════════════════╝");
System.out.print("Pro ^_^ please input:");
do {
nNum = input.nextInt();
switch (nNum) {
case 1:
Registration(); // Implementing the registration function
break;
case 2:
Login(); // Achieve landing effect
break;
case 3:
Raffle(); // Realize the lottery function
break;
default:
System.err.println("Input is wrong!!! /(ㄒoㄒ)/~~ Pro ^_^ please enter again!!!");
break;
}
} while (!(nNum < 4 && nNum > 0));
}
// Implementing the registration function
public static void Registration() {
int nLen; // Calculate the length of the user name
boolean zReturn; // Validation, returns a Boolean value
String szRange; // Determine if the password is true
Scanner input = new Scanner(System.in);
System.out.println("[prize winning system > registration]");
System.out.println("Please fill in the registration information:");
System.out.print("User name (4-16 characters):");
do {
g_szUser = input.next();
nLen = g_szUser.length();
if (nLen < 16 && nLen > 4) {
System.out.println("Pro ^_^ congratulations you register ^_^ success!!!!!!!!!!");
} else {
System.err.println("Pro ^_^ regret Registration failed User name not legitimate ^ _ ~ please enter again!!!");
}
} while (!(nLen < 16 && nLen > 4));
System.out.print("Password (upper and lower case letters plus digit):");
do {
szRange = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[a-zA-Z0-9]*";
g_szCipher = input.next();
zReturn = g_szCipher.matches(szRange);
if (zReturn == false) {
System.err.println("Pro ^_^ password illegal!!!!!!!!!!Please re-enter!!!");
} else {
System.out.println("Pro ^_^ password success!!!!!!!!!!Please keep in mind that yo!!!");
}
} while (zReturn == false);
g_nVIPid = (int) ((Math.random() * 9 + 1) * 1000);
System.out.println();
System.out.println("Please remember your membership card number!!!");
System.out.println("---------------------------------------------------");
System.out.println("User name:" + g_szUser);
System.out.println("cipher:" + g_szCipher);
System.out.println("Membership card number:" + g_nVIPid);
System.out.print("Pro ^_^ will continue( y/n )?");
g_szGoon = input.next();
if (g_szGoon.equals("y")) {
main(null); // Back to the main page
} else {
System.out.println("The system is out, thank you ^_^ !!!");
}
}
// Achieve landing effect
public static void Login() {
int nVIPid; // Membership card number
String szUser; // local user name
String szCipher; // local password
Scanner input = new Scanner(System.in);
System.out.println("[prize winning system > landing]");
System.out.print("Please enter your username:");
do {
szUser = input.next();
if (!(szUser.equals(g_szUser))) {
System.err.println("Pro ^_^ user name input incorrect, please enter again!!!");
}
} while (!(szUser.equals(g_szUser)));
System.out.print("Please enter your password:");
do {
szCipher = input.next();
if (!(szCipher.equals(g_szCipher))) {
System.err.println("Pro ^_^ password is incorrect, please enter again!!!");
}
} while (!(szCipher.equals(g_szCipher)));
System.out.print("Please enter your membership card number:");
do {
nVIPid = input.nextInt();
if (nVIPid != g_nVIPid) {
System.err.println("Pro ^_^ password is incorrect, please enter again!!!");
}
} while (nVIPid != g_nVIPid);
System.out.println();
System.out.println("Welcome:" + g_szUser);
System.out.print("Pro ^_^ will continue( y/n )?");
g_szGoon = input.next();
if (g_szGoon.equals("y")) {
main(null); // Back to the main page
} else {
System.out.println("The system is out, thank you ^_^ !!!");
}
}
// // Realize the lottery function
public static void Raffle() {
int nRVIPid; // local Membership card number
int nRnum1, nRnum2, nRnum3, nRnum4; // Lucky number
Scanner input = new Scanner(System.in);
System.out.println("[prize winning system > draw]");
System.out.print("Please enter your card number:");
do {
nRVIPid = input.nextInt();
if (nRVIPid != g_nVIPid) {
System.err.println("Pro ^_^ password is incorrect, please enter again!!!");
}
} while (nRVIPid != g_nVIPid);
nRnum1 = (int) ((Math.random() * 9 + 1) * 1000);
nRnum2 = (int) ((Math.random() * 9 + 1) * 1000);
nRnum3 = (int) ((Math.random() * 9 + 1) * 1000);
nRnum4 = (int) ((Math.random() * 9 + 1) * 1000);
System.out.println("Current lucky number:");
System.out.println(nRnum1 + "\t" + nRnum2 + "\t" + nRnum3 + "\t" + nRnum4);
if (nRVIPid == nRnum1 || nRVIPid == nRnum2 || nRVIPid == nRnum3 || nRVIPid == nRnum4) {
System.out.println("^_^ you are so lucky!!!!");
} else {
System.out.println("Pro ^_^ regret Not winning!!!!");
}
System.out.print("Pro ^_^ will continue( y/n )?");
g_szGoon = input.next();
if (g_szGoon.equals("y")) {
main(null); // Back to the main page
} else {
System.out.println("The system is out, thank you ^_^ !!!");
}
}
}
奖客富翁系统--NotCare
最新推荐文章于 2022-05-20 17:00:35 发布