java - how to read two parameters of the same type? -


i'm trying create method transfer funds 1 account another..

i'm trying take both sending , receiving account numbers of account class input parameters i'm getting invalid account number exception.

how without generating exceptions? there way make both parameters 'accountnumber'?

public int fundtransfer(int accountnumber, int accountnumber1, int amount) throws invalidaccountnumberexception, insufficientbalanceexception{      account account=searchaccount(accountnumber);     account account1= searchaccount(accountnumber1);      if(amount>0){         account.setamount(account.getamount()-amount);         account1.setamount(account1.getamount()+amount);     }else{         throw new insufficientbalanceexception();     }      throw new invalidaccountnumberexception(); } 

here opinion on code can change:

public int fundtransfer(int accountnumber, int accountnumber1, int amount) throws invalidaccountnumberexception, insufficientbalanceexception{      account account=searchaccount(accountnumber);     account account1= searchaccount(accountnumber1);      if(amount>0){         account.setamount(account.getamount()-amount);         account1.setamount(account1.getamount()+amount);     }else{         throw new insufficientbalanceexception();     } } 

and place throw new invalidaccountnumberexception(); inside searchaccount function


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -