package com.atmTest;
import javax.swing.JOptionPane;
public class ATM {
User[] u={new User("123","123",3000),new User("456","456",6000),new User("111","111",5000)};
public User current;
public ATM(){
JOptionPane.showMessageDialog(null, "欢迎使用XX银行");
current=Login();
if(current==null){
JOptionPane.showMessageDialog(null, "谢谢使用,再见");
System.exit(0);
}
while(true){
String input=JOptionPane.showInputDialog(null,"1.取款\n2.存款\n3.查询\n4.退出");
int in=Integer.parseInt(input);
switch (in) {
case 1:
CheckOut();
break;
case 2:
CheckIn();
break;
case 3:
Show();
break;
case 4:
JOptionPane.showMessageDialog(null, "谢谢使用,再见");
System.exit(0);
break;
default:
break;
}
}
}
private void CheckOut() {
String q=JOptionPane.showInputDialog(null,"请输入取钱额");
int out = Integer.parseInt(q);
if(current.money<out){JOptionPane.showMessageDialog(null, "滚犊子,都没钱还嘚瑟!");}
else {
current.money-=out;
Show();
}
}
/***
* 存钱
*/
private void CheckIn() {
String c=JOptionPane.showInputDialog(null,"输入存钱额");
int M= Integer.parseInt(c);
current.money+=M;
Show();
}
/***
* 查询金额
*/
private void Show() {
JOptionPane.showMessageDialog(null,"当前余额"+ current.money);
}
/***
* 登陆框
* @return
*/
public User Login(){
for (int i = 0; i < 3; i++) {
String userName = JOptionPane.showInputDialog(null, "请输入账户");
String passWord = JOptionPane.showInputDialog(null, "请输入密码");
for (int j = 0; j < u.length; j++) {
if (userName.equals(u[j].code) && passWord.equals(u[j].pwd)) {
JOptionPane.showMessageDialog(null, "登陆成功,欢迎使用XX银行");
return u[j];
}
}
JOptionPane.showMessageDialog(null, "登陆失败请重新输入");
}JOptionPane.showMessageDialog(null, "登陆超过三次,以吞卡");
return null;
}
}
import javax.swing.JOptionPane;
public class ATM {
User[] u={new User("123","123",3000),new User("456","456",6000),new User("111","111",5000)};
public User current;
public ATM(){
JOptionPane.showMessageDialog(null, "欢迎使用XX银行");
current=Login();
if(current==null){
JOptionPane.showMessageDialog(null, "谢谢使用,再见");
System.exit(0);
}
while(true){
String input=JOptionPane.showInputDialog(null,"1.取款\n2.存款\n3.查询\n4.退出");
int in=Integer.parseInt(input);
switch (in) {
case 1:
CheckOut();
break;
case 2:
CheckIn();
break;
case 3:
Show();
break;
case 4:
JOptionPane.showMessageDialog(null, "谢谢使用,再见");
System.exit(0);
break;
default:
break;
}
}
}
private void CheckOut() {
String q=JOptionPane.showInputDialog(null,"请输入取钱额");
int out = Integer.parseInt(q);
if(current.money<out){JOptionPane.showMessageDialog(null, "滚犊子,都没钱还嘚瑟!");}
else {
current.money-=out;
Show();
}
}
/***
* 存钱
*/
private void CheckIn() {
String c=JOptionPane.showInputDialog(null,"输入存钱额");
int M= Integer.parseInt(c);
current.money+=M;
Show();
}
/***
* 查询金额
*/
private void Show() {
JOptionPane.showMessageDialog(null,"当前余额"+ current.money);
}
/***
* 登陆框
* @return
*/
public User Login(){
for (int i = 0; i < 3; i++) {
String userName = JOptionPane.showInputDialog(null, "请输入账户");
String passWord = JOptionPane.showInputDialog(null, "请输入密码");
for (int j = 0; j < u.length; j++) {
if (userName.equals(u[j].code) && passWord.equals(u[j].pwd)) {
JOptionPane.showMessageDialog(null, "登陆成功,欢迎使用XX银行");
return u[j];
}
}
JOptionPane.showMessageDialog(null, "登陆失败请重新输入");
}JOptionPane.showMessageDialog(null, "登陆超过三次,以吞卡");
return null;
}
}