closeAccount information problem
I have two methods: closeAccount and deleteCustomer. Everthing is okay when I delete a customer without accounts or when I close an account but not the customer. But when I delete a customer with several accounts I don´t know how to inform about the closed accounts.
Code:
public String closeAccount(String valdKundPNr, int valtKontoNr){
Account removeAccount = null;
for(int a = 0; a < accounts.size(); a++){
Account konto = accounts.get(a);
if(valtKontoNr==konto.accountNumber){
if(konto.getKontoTyp().equals("savingAccount")){
konto.countInterest(valtKontoNr, konto.getInterestRate());
info=("Account Statement\n" + konto.toString() +
"\n Beloppet utbetalas på angivet avräkningskonto.");
}
else if(konto.getKontoTyp().equals("creditAccount")){
konto.countInterest(valtKontoNr,konto.getInterestRate());
info=("Account Statement\n" + konto.toString() +
"\n Vid positivt saldo utbetalas beloppet till avräkningskonto." +
"\n Vid negativt saldo ska du betala tillbaka skulden till banken.");
}
removeAccount = konto;
}
}
accounts.remove(removeAccount);
return info;
}
Code:
public String deleteCustomer(String valdKundPNr){
String str = "";
for(int a=0; a<accounts.size(); a++){
Account konto = accounts.get(a);
if(valdKundPNr.equals(konto.getPNumber())){
str += closeAccount(valdKundPNr, konto.getAccountNumber());
a--;
}
}
String taBortKund = valdKundPNr;
int i;
int remove = -1;
for (i=0; i<customers.size(); i++){
if(taBortKund.equals(customers.get(i).getPNumber())){
remove = i;
break;
}
}
if(remove != -1)
customers.remove(i);
return str + "\n" + ("Customer with pNumber " + valdKundPNr + " is deleted from the register.");
}
If I have a customer with one savingAccount and one creditAccount - how do I get information about those accounts togehter with information that the customer is deleted? The information is presented in a GUI textarea.
Re: closeAccount information problem
The problem is now solved.