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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -