Ejemplo n.º 1
0
 public TransferTransaction(Account fromAccount, Account toAccount, decimal amount)
 {
     this._fromAccount = fromAccount;
     this._toAccount   = toAccount;
     this._amount      = amount;
     this._withdraw    = new WithdrawTransaction(_fromAccount, this._amount);
     this._deposit     = new DepositTransaction(_toAccount, this._amount);
 }
Ejemplo n.º 2
0
        private static void DoDeposit(Bank bank)
        {
            //Search for an account
            Account account = FindAccount(bank);

            //Take actions if the account is detected
            if (account != null)
            {
                Console.WriteLine("Input amount");
                decimal            amount             = InputToDec(Console.ReadLine());
                DepositTransaction currentTransaction = new DepositTransaction(account, amount);


                //Ask user to proceed, take action
                if (YNQuestion("Proceed? Y/N"))
                {
                    bank.ExecuteTransaction(currentTransaction);
                }
                else
                {
                    Console.WriteLine("Transaction cancelled");
                }

                //Ask user, then verify user input

                if (YNQuestion("Print transaction details? Y/N"))
                {
                    currentTransaction.Print();
                }
            }
            else
            {
                Console.WriteLine("Deposit canceled!");
            }

            Console.ReadLine();
        }
Ejemplo n.º 3
0
 public void ExecuteTransaction(DepositTransaction transaction)
 {
     transaction.Execute();
 }
        // Methodd
        private static void DoDeposit(Account account)
        {
            Console.WriteLine("Input amount");
            decimal            amount             = InputToDec(Console.ReadLine());
            DepositTransaction currentTransaction = new DepositTransaction(account, amount);


            //Ask user to proceed, and veryfy user input.
            Console.WriteLine("Proceed? Y/N");
            string proceed;

            do
            {
                proceed = Console.ReadLine().ToLower();
                switch (proceed)
                {
                case "y":
                {
                    currentTransaction.Execute();
                    break;
                }

                case "n":
                {
                    break;
                }

                default:
                {
                    Console.WriteLine("Unknown option, please try again");
                    proceed = Console.ReadLine().ToLower();
                    break;
                }
                }
            } while (proceed != "y" && proceed != "n" && string.IsNullOrEmpty(proceed));

            //Ask user, then verify user input
            Console.WriteLine("Print transaction details? Y/N");
            string print;

            do
            {
                print = Console.ReadLine().ToLower();
                switch (print)
                {
                case "y":
                {
                    currentTransaction.Print();
                    break;
                }

                case "n":
                {
                    break;
                }

                default:
                {
                    Console.WriteLine("Unknown option, please try again");
                    print = Console.ReadLine().ToLower();
                    break;
                }
                }
            } while (print != "y" && print != "n" && string.IsNullOrEmpty(print));

            Console.ReadLine();
        }