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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -