Ejemplo n.º 1
0
        //Method to perform a trasaction operation
        public static void DoTransaction(Bank bank)
        {
            try
            {
                Console.WriteLine("\n.....Debit.....");
                Account acc1 = FindAccount(bank);

                //If account1 is found in the FindAccount method, then ask the amount and account2
                if (acc1 != null)
                {
                    decimal transactionAmount;
                    Console.Write("Please enter the amount to do transaction: ");
                    transactionAmount = Convert.ToDecimal(Console.ReadLine());

                    Console.WriteLine("\n.....Credit.....");
                    Account acc2 = FindAccount(bank);

                    //If account2 is found in the FindAccount method, then do the transfer transaction
                    if (acc2 != null)
                    {
                        TransferTransaction transaction = new TransferTransaction(acc1, acc2, transactionAmount);

                        bank.ExecuteTransaction(transaction);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error! : " + e.Message);
            }
        }
Ejemplo n.º 2
0
        //Method to perform a withdraw operation
        public static void DoWithdraw(Bank bank)
        {
            try
            {
                Account acc = FindAccount(bank);

                //If account is found in the FindAccount method, then do the withdraw
                if (acc != null)
                {
                    decimal withdrawAmount;

                    Console.Write("Please enter the amount to withdraw: ");
                    withdrawAmount = Convert.ToDecimal(Console.ReadLine());

                    WithdrawTransaction transaction = new WithdrawTransaction(acc, withdrawAmount);

                    bank.ExecuteTransaction(transaction);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error! : " + e.Message);
            }
        }
Ejemplo n.º 3
0
        //Method to perform a deposit operation
        public static void DoDeposit(Bank bank)
        {
            try
            {
                Account acc = FindAccount(bank);

                //If account is found in the FindAccount method, then do the deposit
                if (acc != null)
                {
                    decimal depositAmount;

                    Console.Write("Please enter the amount to deposit: ");
                    depositAmount = Convert.ToDecimal(Console.ReadLine());

                    DepositTransaction transaction = new DepositTransaction(acc, depositAmount);

                    bank.ExecuteTransaction(transaction);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error! : " + e.Message);
            }
        }