Esempio n. 1
0
        public void Deposit(double amount)
        {
            if (amount < 0)
            {
                NegativeAmountException e = new NegativeAmountException($"Amount was {amount} kr.");
                throw e;
            }

            _balance = _balance + amount;
        }
        public void Withdraw(double amount)
        {
            if (amount < 0)
            {
                NegativeAmountException e = new NegativeAmountException();
                throw e;
            }

            if (_balance < amount)
            {
                throw new WithdrawAmountTooLargeException();
            }

            _balance = _balance - amount;
        }
Esempio n. 3
0
        public void Withdraw(double amount)
        {
            if (amount < 0)
            {
                NegativeAmountException e = new NegativeAmountException($"Amount was {amount} kr.");
                throw e;
            }

            if (_balance < amount)
            {
                WithdrawAmountTooLargeException e = new WithdrawAmountTooLargeException($"Amount was {amount} kr., balance was {_balance} kr.");
                throw e;
            }

            _balance = _balance - amount;
        }