Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }