コード例 #1
0
    public static void Main(string[] args)
    {
        Account jack = Banker.OpenCurrentAccount();

        jack.Deposit(20000);
        Account jill = Banker.OpenSavingsAccount();

        jill.Deposit(15000);

        try
        {
            double amt = double.Parse(args[0]);
            jill.Transfer(amt, jack);
            Console.WriteLine("Transfer succeeded.");
        }
        catch (InsufficientFundsException)
        {
            Console.WriteLine("Transfer failed due to lack of funds!");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
        Console.WriteLine($"Jack's Account ID is {jack.Id} and Balance is {jack.Balance}");
        Console.WriteLine($"Jill's Account ID is {jill.Id} and Balance is {jill.Balance}");
    }
コード例 #2
0
    public static void Main(string[] args)
    {
        Account jack = Banker.OpenCurrentAccount();

        jack.Deposit(20000);

        Account jill = Banker.OpenSavingsAccount();

        jill.Deposit(15000);

        try
        {
            double payment = double.Parse(args[0]);
            jill.Transfer(payment, jack);
            Console.WriteLine("Payment transferred.");
        }
        catch (InsufficientFundsException)
        {
            Console.WriteLine("Transfer failed due to lack of funds!");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: {0}", ex.Message);
        }

        Console.WriteLine("Jack's Account ID is {0} and Balance is {1:0.00}", jack.Id, jack.Balance);
        Console.WriteLine("Jill's Account ID is {0} and Balance is {1:0.00}", jill.Id, jill.Balance);
    }
コード例 #3
0
    public static void Main(string[] args)
    {
        Account jack = Banker.OpenCurrentAccount();

        jack.Deposit(15000);

        Account jill = Banker.OpenSavingsAccount();

        jill.Deposit(10000);

        try
        {
            double payment = double.Parse(args[0]);
            jill.Transfer(payment, jack);
            Console.WriteLine("Payment transferred.");
        }
        catch (InsufficientFundsException)
        {
            Console.WriteLine("Payment transfer failed due to lack of funds!");
        }
        catch
        {
            Console.WriteLine("Usage: abstractclasstest payment-to-transfer");
        }

        Console.WriteLine($"Jack's Account ID is {jack.Id} and Balance is {jack.Balance}");
        Console.WriteLine($"Jill's Account ID is {jill.Id} and Balance is {jill.Balance}");
    }
コード例 #4
0
    public static void Main()
    {
        Account jack = Banker.OpenCurrentAccount();

        jack.Deposit(20000);

        Account jill = Banker.OpenSavingsAccount();

        jill.Deposit(10000);

        try
        {
            Console.Write("Amount to transfer: ");
            double amt = Convert.ToDouble(Console.ReadLine());
            jill.Transfer(amt, jack);
            Console.WriteLine("Funds transferred.");
        }
        catch (AccountingException ex) when(ex.Cause == FaultType.InsufficientFunds)
        {
            Console.WriteLine("Transfer failed due to lack of funds!");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        Console.WriteLine($"Jack's Account ID is {jack.Id} and Balance is {jack.Balance:0.00}");
        Console.WriteLine($"Jill's Account ID is {jill.Id} and Balance is {jill.Balance:0.00}");
    }
コード例 #5
0
    public static void Main()
    {
        Account[] bank = new Account[4];
        bank[0] = Banker.OpenSavingsAccount();
        bank[0].Deposit(5000);
        bank[1] = Banker.OpenCurrentAccount();
        bank[1].Deposit(20000);
        bank[2] = Banker.OpenCurrentAccount();
        bank[2].Deposit(30000);
        bank[3] = Banker.OpenSavingsAccount();
        bank[3].Deposit(35000);

        PayAnnualInterest(bank);
        DeductTax(bank);

        foreach (var acc in bank)
        {
            Console.WriteLine("{0, -10}{1, 12:0.00}", acc.Id, acc.Balance);
        }
    }
コード例 #6
0
    public static void Main()
    {
        Account[] bank = new Account[4];
        bank[0] = Banker.OpenSavingsAccount();
        bank[0].Deposit(5000);
        bank[1] = Banker.OpenCurrentAccount();
        bank[1].Deposit(25000);
        bank[2] = Banker.OpenCurrentAccount();
        bank[2].Deposit(35000);
        bank[3] = Banker.OpenSavingsAccount();
        bank[3].Deposit(35000);

        PayAnnualInterest(bank);
        DeductTax(bank);

        foreach (Account acc in bank)
        {
            Console.WriteLine($"{acc.Id}\t{acc.Balance:0.00}");
        }
    }
コード例 #7
0
    public static void Main()
    {
        Account[] bank = new Account[5];
        bank[0] = Banker.OpenSavingsAccount();
        bank[0].Deposit(5000);
        bank[1] = Banker.OpenCurrentAccount();
        bank[1].Deposit(20000);
        bank[2] = Banker.OpenSavingsAccount();
        bank[2].Deposit(25000);
        bank[3] = Banker.OpenCurrentAccount();
        bank[3].Deposit(40000);
        bank[4] = Banker.OpenSavingsAccount();
        bank[4].Deposit(45000);

        PayQuarterlyInterest(bank);
        DeductAnnualTax(bank);

        foreach (var acc in bank)
        {
            Console.WriteLine($"{acc.Id}\t{acc.Balance}");
        }
    }
コード例 #8
0
    public static void Main(string[] args)
    {
        Account jack = Banker.OpenCurrentAccount();

        jack.Deposit(15000);

        Account jill = Banker.OpenSavingsAccount();

        jill.Deposit(10000);

        double amt = double.Parse(args[0]);

        try
        {
            jill.Transfer(amt, jack);
        }
        catch (AccountingException ex) when(ex.Cause == FaultType.InsufficientFunds)
        {
            Console.WriteLine("Transfer failed due to lack of funds!");
        }

        Console.WriteLine("Jack's Account ID is {0} and Balance is {1:0.00}", jack.Id, jack.Balance);
        Console.WriteLine("Jill's Account ID is {0} and Balance is {1:0.00}", jill.Id, jill.Balance);
    }