Example #1
0
        static void Main(string[] args)
        {
            BankAccount savingAccount  = new SavingBankAccount("Sarvesh", "S12345");
            BankAccount currentAccount = new CurrentBankAccount("Mark", "C12345");

            TryCatchAmount(savingAccount.Deposit, 40000);
            TryCatchAmount(savingAccount.Deposit, -1);      // non-positive deposit amount exc
            TryCatchAmount(savingAccount.Deposit, 50001);   // maximum deposit amount exc
            TryCatchAmount(savingAccount.Withdraw, 100000); // min balanse exc
            TryCatchAmount(savingAccount.Withdraw, 15000);  // report exc
            TryCatchAmount(savingAccount.Withdraw, 1000);
            TryCatchAmount(savingAccount.Withdraw, 1000);
            TryCatchAmount(savingAccount.Withdraw, 1000);// fourth withdraw exc

            TryCatchReport(savingAccount.GenerateAccountReport);

            Console.WriteLine();
            TryCatchAmount(currentAccount.Deposit, 190000);
            TryCatchAmount(currentAccount.Withdraw, 1000);
            TryCatchAmount(currentAccount.Deposit, -1000);      // non-positive deposit amount exc
            TryCatchAmount(currentAccount.Deposit, 1100000000); // maximum deposit amount exc
            TryCatchAmount(currentAccount.Withdraw, 190000);    // min balanse exc

            TryCatchReport(currentAccount.GenerateAccountReport);

            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            ILogger logger = new ConsoleLogger();

            try
            {
                BankAccount savingAccount  = new SavingBankAccount("Sarvesh", "S12345", logger);
                BankAccount currentAccount = new CurrentBankAccount("Mark", "C12345", logger);

                savingAccount.Deposit(400000);
                savingAccount.Withdraw(100000000);
                //savingAccount.Withdraw(1000);
                //savingAccount.Withdraw(1000);

                // Generate Report
                savingAccount.GenerateAccountReport();

                currentAccount.Deposit(190000);
                currentAccount.Withdraw(1000);
                currentAccount.GenerateAccountReport();
            }
            catch (ArgumentNullException e)
            {
                logger.Write(e.Message);
            }
            catch (User_Defined_Exceptions.MinimumBalanceLimitException e)
            {
                logger.Write(e.Message);
            }
            catch (User_Defined_Exceptions.ExceedDepositAmountException e)
            {
                logger.Write(e.Message);
            }
            catch (User_Defined_Exceptions.ExceedThriceWithdrawAmountException e)
            {
                logger.Write(e.Message);
            }
            catch (User_Defined_Exceptions.GenerateReportException e)
            {
                logger.Write(e.Message);
            }

            Console.ReadLine();
        }