奖客富翁系统--NotCare

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 ^_^ !!!");
        }
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值