コード例 #1
0
        public void MakeDeposit(double amount, DateTime date, string note)
        {
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), "Amount of deposit must be positive");
            }
            var deposit = new BankTransaction(amount, date, note);

            allTransactions.Add(deposit);
        }
コード例 #2
0
        public void MakeWithdrawal(double amount, DateTime date, string note)
        {
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), "Amount of withdrawal must be positive");
            }
            if (Balance - amount < 0)
            {
                throw new InvalidOperationException("Not sufficient funds for this withdrawal");
            }
            var withdrawal = new BankTransaction(-amount, date, note);

            allTransactions.Add(withdrawal);
        }
コード例 #3
0
        //methods
        public void AddInterests(double interestRate, DateTime date, string note)
        {
            if (interestRate > 0 && interestRate <= 22)
            {
                balance += balance * interestRate;

                var item = new BankTransaction(balance, date, note);

                allTransactions.Add(item);
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(interestRate), "The interestRate is out of range");
            }
        }