Ejemplo n.º 1
0
        //check push
        void Run()
        {
            Account checking = new Account("Checking");

            checking.Deposit(300.00);

            Savings savings = new Savings("Savings with Interest", 0.1);             // creates a new instance of Savings with name and interest rate

            savings.Deposit(18000.00);
            savings.PayMonthlyInterest();

            //creates an array containing all properties of savings and checking account properties
            // then prints properties of both accounts
            List <Account> myAccounts = new List <Account>();

            myAccounts.Add(savings);
            myAccounts.Add(checking);
            foreach (var account in myAccounts)
            {
                Console.WriteLine(account.ToPrint());
            }
            // some account class methods
            checking.Withdraw(20.00);
            savings.Transfer(100.00, checking);
            foreach (var account in myAccounts)
            {
                Console.WriteLine(account.ToPrint());
            }
        }
Ejemplo n.º 2
0
        // Run method pushed up to GitHub

        void TestAccount()
        {
            Account checking = new Account();

            checking.SetName("Checking 1");
            checking.Withdraw(100.00);
            checking.Deposit(50.00);
            checking.Deposit(-100.00);
            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Savings savings = new Savings("My Savings Account");

            savings.IntRate = 0.10;
            savings.Deposit(70.00);
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.Transfer(30.00, checking);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            checking.Transfer(-10.00, savings);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.Transfer(100.00, checking);

            Console.WriteLine($"Account Nbr:{checking.getNumber()}, Name: {checking.GetName()}, balance is {checking.CheckBalance()}");
            Console.WriteLine($"Account Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            savings.PayMonthlyInterest();

            Console.WriteLine($"Savings Nbr:{savings.getNumber()}, Name: {savings.GetName()}, balance is {savings.CheckBalance()}");

            Savings sav1 = new Savings("Greg's Savings with Interest", 0.05);
        }