コード例 #1
0
    private static void DoDeposit(Bank toBank)
    {
        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        String  input;
        decimal deposit = 0;

        Console.WriteLine("How much would you like to deposit?: ");

        try
        {
            input   = Console.ReadLine();
            deposit = Convert.ToDecimal(input);
        }
        catch (System.FormatException)
        {
            Console.WriteLine("Not a number");
        }

        DepositTransaction depositT = new DepositTransaction(toAccount, deposit);

        toBank.ExecuteTransaction(depositT);
        depositT.Print();
    }
コード例 #2
0
    private static void DoDeposit(Bank toBank)
    {
        Decimal DepositAmount;

        Account toAccount = FindAccount(toBank);

        if (toAccount == null)
        {
            return;
        }

        try
        {
            Console.WriteLine("How much would you like to Deposit? ");
            //Read in the amount
            DepositAmount = Convert.ToDecimal(Console.ReadLine());
        }
        catch
        {
            DepositAmount = 0;
        }
        //create the deposit transaction
        DepositTransaction deposittransac = new DepositTransaction(toAccount, DepositAmount);

        //tell toBank to run the transaction
        toBank.ExecuteTransaction(deposittransac);
        //Ask the transaction to Print.
        deposittransac.Print();
    }
コード例 #3
0
 public static void ExecuteTransaction(DepositTransaction transaction)
 {
     transaction.Execute();
     transaction.Print();
 }