public string addMoney(DigitalWallet digitalWallet, int amount) { if (!this.commonValidation(digitalWallet, amount)) { return("We can not do this transaction"); } digitalWallet.setBalance(digitalWallet.getWalletBalance() + amount); return(returnBalance(digitalWallet)); }
public string payMoney(DigitalWallet digitalWallet, int amount) { if (!this.commonValidation(digitalWallet, amount)) { return("We can not do this transaction"); } // Final balance after possible transaction int finalBalance = 0; finalBalance = digitalWallet.getWalletBalance() - amount; if (finalBalance < 0) { return("Insufficient balance"); } else { digitalWallet.setBalance(finalBalance); } return(returnBalance(digitalWallet)); }