Exemplo n.º 1
0
        public bool Withdraw(Money amount)
        {
            // TODO: This should generate a transaction
            if (_balance < amount)
            {
                throw new InsufficientFundsException();
            }

            if (amount.Amount < 0)
            {
                throw new InvalidAmountException();
            }

            // Remove balance from this account
            _balance = _balance - amount;

            return true;
        }
Exemplo n.º 2
0
        public bool Transfer(Account a, Money amount)
        {
            if (_balance < amount)
            {
                throw new InsufficientFundsException();
            }

            if (amount.Amount < 0)
            {
                throw new InvalidAmountException();
            }

            // Remove balance from this account
            _balance = _balance - amount;

            // Add balance to Account a
            a._balance = a._balance + amount;

            return true;
        }
Exemplo n.º 3
0
 public Account(Money balance)
 {
     this._balance = balance;
 }