package xinyunchoujiang;
import java.util.Scanner;
public class CaiDan {
static Scanner sc = new Scanner(System.in);
static String name = "";
static String pass = "";
static int random = 0;
static boolean isReg = false;
static boolean isLogin = false;
static int [] jiang = new int [4];
public static void main(String[] args) {
menu();
}
public static void menu() {
Scanner sc = new Scanner(System.in);
String ji = "";
do {
System.out.println("*****欢迎进入奖客富翁系统*****");
System.out.println("\t1.注册");
System.out.println("\t2.登录");
System.out.println("\t3.抽奖");
System.out.println("***************************");
System.out.print("请选择菜单:");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.println("[奖客富翁系统 > 注册]");
reg();
break;
case 2:
System.out.println("[奖客富翁系统 > 登录]");
login();
break;
case 3:
System.out.println("[奖客富翁系统 > 抽奖]");
if(isLogin==true){
choujiang();
}else{
System.out.println("还没登陆呢,请登录");
}
break;
default:
System.out.println("[您的输入有误!]");
break;
}
System.out.println("继续吗?(y/n)");
ji = sc.next();
} while (ji.equals("y"));
System.out.println("已经退出!!!");
}
public static void reg() {
System.out.println("请输入用户名:");
name = sc.next();
System.out.println("请输入密码:");
pass = sc.next();
random = (int) (Math.random() * 10000);
System.out.println("用户名\t密码\t会员卡号");
System.out.println(name + "\t" + pass + "\t" + random);
isReg = true;
}
public static void login(){
if(isReg==true){
for(int i = 1;i<=3;i++){
System.out.println("请输入用户名:");
String name1 = sc.next();
System.out.println("请输入密码:");
String pass1 = sc.next();
if(name1.equals(name)&&pass1.equals(pass)){
System.out.println("登录成功");
isLogin = true;
break;
}else if(i<3){
System.out.println("还有"+(3-i)+"次机会");
}else{
System.out.println("没有机会了");
}
}
}else{
System.out.println("还没有注册呢");
}
}
public static void choujiang(){
System.out.println("请输入您的卡号:");
int kahao = sc.nextInt();
for(int i = 0;i<4;i++){
jiang[i] = (int)(Math.random()*10000);
}
System.out.println("中奖的卡号是:");
for (int i : jiang) {
System.out.print(i+"\t");
}
for (int i = 0; i < jiang.length; i++) {
if(kahao==jiang[i]){
System.out.println("您中奖啦");
break;
}
}
System.out.println("\n没有中奖呢");
}
}