我想以具有ID和帐号的客户身份登录系统。输入客户的号码后,我会毫不费力地通过ArrayList
个客户。
当我输入帐号时,我的程序会浏览该特定客户的ArrayList
个帐户,并打开一个与该帐户无关的对话框。
我希望ArrayList
找到输入帐号并为该特定号码进行交易。
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame(" ");
boolean found1 = false;
boolean found = false;
String a = JOptionPane.showInputDialog("Please enter the ID number: ");
for(Customer aCustomer: customers){
System.out.println("ID: " + a + " = " + aCustomer.getId());
int num = Integer.parseInt(a);
if(num == aCustomer.getId()){
BankInterface.setCurrentCustomer(aCustomer);
found1 = true;
break;
}
}
if(!found1){
JOptionPane.showMessageDialog(frame, "There is no customer with this ID number", "Please try again", JOptionPane.WARNING_MESSAGE);
}
if(found1){
String b = JOptionPane.showInputDialog("Please enter the account number: ");
int number = Integer.parseInt(b);
for(CustomerAccount cu: BankInterface.getCurrentCustomer().getAccounts()){
System.out.println("Account: " + b + " = " + cu.getAccountNumber());
if(number == cu.getAccountNumber()){
//BankInterface.setCurrentCustomer(aCustomer);
BankInterface.setCurrentAccount(cu);
new WithdrawDepositDialog(BankInterface.this, customers);
found = true;
}
}
}
}
});
对话框打开后,我试图获取我在驱动程序类中设置的内容以连接特定帐号。
顺便说一句,我将事务添加到我在Account类中的事务数组中:
AccountTransaction transactions = new AccountTransaction(date, type, amount);
BankInterface.getCurrentCustomer();
BankInterface.getCurrentAccount();
int arraySize = BankInterface.getCurrentCustomer().getAccounts().size();
Customer tempCust = BankInterface.getCurrentCustomer();
for(Customer c : customers){
if(c == tempCust){
for(int i = 0; i < arraySize; i++){
c.getAccounts().get(i).getTransactions().add(transactions);
c.getAccounts().get(i).withdraw(amount);
}
}
}