📄 atmapp.java
字号:
/*
* ATMApp.java
*/
package atm;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
/**
* The main class of the application.
*/
/**
* 银行类
* 存储帐户信息
* @author 刘超
*/
class BankAccount{
private String accountNum;//账号
private String psw;//密码
private String info;//帐户信息
private double money;//帐户余额
public BankAccount(String cN,String p,String i,double m){
accountNum = cN;
psw = p;
money = m;
info = i;
}
public String getCount(){ return accountNum; }
public String getPSW(){ return psw; }
public String getINFO(){ return info; }
public double getMoney(){ return money; }
//-----更改密码
public void changePSW(String ps){
psw = ps;
}
//-----------取钱或者存钱
public void setMoney(double newMoney){
money = newMoney;
}
//------修改用户信息
public void changeINFO(String s){
info = s;
}
}
/**
* 存储所有银行账户的类
* @author 刘超
*/
class Accounts{
private final int MAXNUM= 10;
private int items;
private BankAccount accountArray[];
public Accounts(){
accountArray = new BankAccount[MAXNUM];
items = 0;
}
//存储帐户
public void insertAccount(String ID,String psw,String info,double my){
accountArray[items++] = new BankAccount(ID,psw,info,my);
}
//验证帐户
public BankAccount findAccount(String ID,String psw){
for(int j=0;j<items;j++)
if(accountArray[j].getCount().equals(ID)&&
accountArray[j].getPSW().equals(psw))
return accountArray[j];
return null;
}
}
public class ATMApp extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
show(new ATMView(this));
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of ATMApp
*/
public static ATMApp getApplication() {
return Application.getInstance(ATMApp.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(ATMApp.class, args);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -