Results 1 to 2 of 2
  1. #1
    ostkanten is offline Member
    Join Date
    Jul 2012
    Posts
    37
    Rep Power
    0

    Default 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.

    Java 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;
    	}
    Java 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.

  2. #2
    ostkanten is offline Member
    Join Date
    Jul 2012
    Posts
    37
    Rep Power
    0

    Default Re: closeAccount information problem

    The problem is now solved.

Similar Threads

  1. Account information problem
    By ostkanten in forum New To Java
    Replies: 2
    Last Post: 09-14-2012, 07:13 PM
  2. Replies: 1
    Last Post: 08-02-2012, 04:01 AM
  3. Replies: 2
    Last Post: 07-26-2011, 08:48 AM
  4. Replies: 5
    Last Post: 04-27-2011, 10:14 PM
  5. Need information...
    By nikkka in forum New To Java
    Replies: 1
    Last Post: 03-07-2011, 03:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •