package android.xiaolan.atm.tools;
import java.util.Scanner;
public class Main {
public static String user;
public static Scanner sc = new Scanner(System.in);
public static int a = 3;
public static String[][] xiaolan666 = {
{ "admin", "admin1", "admin2", "admin3", "admin4", },
{ "520", "520", "520", "520", "520" },
{ "105500", "2000", "5000", "2000", "5000" }, };
public static int admin;
public static int xyz = 0;
public static int adminmony;
public static void main(String[] args) {
intView(">>请输入对应的序号选项:");
}
public static void intView(String xiaolan) {
System.out.println("\n-----------------------------");
System.out.println(" 欢迎登录工商银行登录系统");
System.out.println("\t1. 登录");
System.out.println("\t2. 退卡");
System.out.println("-----------------------------");
System.out.print(xiaolan);
int o = sc.nextInt();
switch (o) {
case 1:
Login();
break;
case 2:
System.out.println("退出成功\n欢迎下次光临");
break;
default:
intView("\n系统没有您要选择的序号,请重新输入...");
}
}
public static void Login() {
boolean b1 = false;
do {
System.out.println("请输入卡号和密码,您还有" + a + "次机会\n");
System.out.print("请输入卡号:");
user = sc.next();
System.out.print("请输入密码:");
String password = sc.next();
for (int i = 0; i < xiaolan666[0].length; i++) {
if (xiaolan666[0][i].equals(user)&& xiaolan666[1][i].equals(password)) {
admin = i;
System.out.println("登录成功\n\n");
int xiaolan = Integer.valueOf(xiaolan666[2][i]).intValue();
xyz = xiaolan;
b1 = true;
item(">>请输入对应的序号选项:");
break;
}
}
if(b1){
break;
}
a--;
} while (a > 0);
if (a == 0) {
System.out.println("3次尝试机会已经使用完,卡已经锁定,请到工商银行柜台办理!");
}
}
public static void item(String s) {
System.out.println("\n-----------------------------");
System.out.println("\t1. 查询余额");
System.out.println("\t2. 转账");
System.out.println("\t3. 存款");
System.out.println("\t4. 取款");
System.out.println("\t5. 退卡");
System.out.println("-----------------------------");
System.out.println(s);
int o = sc.nextInt();
switch (o) {
case 1:
System.out.println("您当前余额为:" + xyz + "元");
Return("是否返回上一级<Y是/N否>");
break;
case 2:
zhuanzhang("请输入要转账的账户:");
Return("是否返回上一级<Y是/N否>");
break;
case 3:
cunkuan();
Return("是否返回上一级<Y是/N否>");
break;
case 4:
qukuan();
Return("是否返回上一级<Y是/N否>");
break;
case 5:
System.out.println("退卡成功\n欢迎下次光临");
a = 3;
intView(">>请输入对应的序号选项:");
break;
default:
item("\n系统没有您要选择的序号,请重新输入...");
break;
}
}
public static void Return(String s) {
System.out.println(s);
char c = sc.next().charAt(0);
switch (c) {
case 'y':
item("请继续交易或者选择退卡");
break;
case 'n':
System.out.println("退卡成功\n欢迎下次光临");
a = 3;
intView(">>请输入对应的序号选项:");
break;
case 'Y':
item("请继续交易或者选择退卡");
break;
case 'N':
System.out.println("退卡成功\n欢迎下次光临");
a = 3;
intView(">>请输入对应的序号选项:");
break;
default:
Return("\n系统没有您要选择的序号,请重新输入...\n是否返回上一级<Y是/N否>");
}
}
public static void qukuan() {
System.out.print("请输入取款金额:");
int f = sc.nextInt();
if (xyz < f) {
System.out.println("您的账户余额不足" + f + "元");
qukuan();
return;
}
xyz = xyz - f;
String x1= String.valueOf(xyz);
xiaolan666[2][admin] = x1;
System.out.println("取现" + f + "元,账户剩余" + xyz + "元");
}
public static void zhuanzhang(String s1) {
System.out.println(s1);
String useradmin = sc.next();
if (useradmin.equals(xiaolan666[0][admin])) {
zhuanzhang("不能给自己转账\n请重新输入要转账的账户:");
} else {
boolean b = false;
for (int k = 0; k < xiaolan666[0].length; k++) {
if (useradmin.equals(xiaolan666[0][k])) {
adminmony = k;
b = true;
xiaolan("请输入金额:");
break;
}
}
if (!b) {
System.out.println("用户不存在");
}
}
}
public static void xiaolan(String a) {
System.out.println(a);
int f = sc.nextInt();
if (xyz < f) {
xiaolan("您的账户余额不足" + f + "元\n请重新输入金额:");
} else {
xyz = xyz - f;
String x= String.valueOf(xyz);
xiaolan666[2][admin] = x;
String str1= xiaolan666[2][adminmony] ;
int xp = Integer.valueOf(str1).intValue();
int xp1 = xp + f;
String e = String.valueOf(xp1);
xiaolan666[2][adminmony] = e;
System.out.println("已成功转出" + f + "元,账户剩余" + xyz + "元");
}
}
public static void cunkuan() {
System.out.print("请输入存入金额:");
int f = sc.nextInt();
xyz = xyz + f;
String str = String.valueOf(xyz);
xiaolan666[2][admin] = str;
System.out.println("系统已将" + f + "元,账户剩余" + xyz + "元");
}
}