Пример #1
0
        private static void InnerExceptionTest()
        {
            try
            {
                CurrentAccount account1 = new CurrentAccount(45, 125);
                CurrentAccount account2 = new CurrentAccount(43, 127);

                account2.BankTransfer(50, account1);
                account1.WithdrawalAmount(20);

                Console.WriteLine("[Account1] - Agency Number: " + account1.AgencyNumber + " | Account Number: " + account1.AccountNumber + " | Bank Balance R$ " + account1.BankBalance + ",00");
                Console.WriteLine("[Account2] - Agency Number: " + account2.AgencyNumber + " | Account Number: " + account2.AccountNumber + " | Bank Balance R$ " + account2.BankBalance + ",00");
            }
            catch (FinancialOperationException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
Пример #2
0
        public void BankTransfer(double value, CurrentAccount targetAccount)
        {
            if (value < 0)
            {
                throw new ArgumentException("Invalid transfer amount.", nameof(value));
            }

            try
            {
                WithdrawalAmount(value);
            }
            catch (InsufficientBalanceException e)
            {
                TransferCounterNotAllowed++;
                throw new FinancialOperationException("Operation not performed.", e);
            }

            targetAccount.BankDeposit(value);
        }