예제 #1
0
        static void Main(string[] args)
        {
            Checking ckg = new Checking();

            ckg.Number = "1005";
            ckg.Name   = "New Checking";
            ckg.Deposit(4500);
            ckg.ChkPayment(100, 1000);

            Savings sav1 = new Savings();

            sav1.Number = "1004";
            sav1.Name   = "New Savings";
            sav1.ChangeRate(0.02); //Added from savings method to raise/lower IntRate

            MoneyMarket MM = new MoneyMarket();

            MM.Number  = "1003";
            MM.Name    = "Money Market";
            MM.IntRate = 0.15;

            MM.Deposit(10989);
            decimal MMInterestPaid = MM.CalcInterest(12);

            MM.PayInterest(MMInterestPaid);

            Account[] accounts = new Account[] { sav1, MM, ckg };

            foreach (Account acct in accounts)
            {
                Console.WriteLine(acct.Print());
            }

            Console.WriteLine(sav1.Print());
            Console.WriteLine(MM.Print());

/*
 *          Console.WriteLine($"Your Money Market Account balance is ${MM.GetBalance()}");
 *
 *          bool ItWorked = MM.TransferTo(sav1, 50);
 *          Console.WriteLine($"Your Money Market Account balance is ${MM.GetBalance()}");
 *          Console.WriteLine($"Your New Savings Account balance is ${sav1.GetBalance()}");
 *
 *          Savings sav = new Savings(); //creating a new instance of the savings class, new savings account
 *          sav.Number = "1002";
 *          sav.Name = "Savings 1";
 *          sav.IntRate = 0.05;
 *
 *          sav.Deposit(200);
 *          sav.Withdraw(100);
 *          decimal interestToBePaid = sav.CalcInterest(6);
 *          sav.PayInterest(interestToBePaid);
 *          decimal savbal = sav.GetBalance();
 *          Console.WriteLine($"Savings balance is {savbal}.");
 *
 *          sav.Deposit(100);
 *          savbal = sav.GetBalance();
 *          Console.WriteLine($"Savings balance is {savbal}.");
 *
 *          sav.Withdraw(150);
 *          savbal = sav.GetBalance();
 *          Console.WriteLine($"Savings balance is {savbal}.");
 *
 *
 *
 *          /*
 *                      Account acct = new Account(); //Created a new account instance
 *                      acct.Number = "1001";     //Defined the variable=acct and the property name = number
 *                      acct.Name = "Test Account";
 *
 *                      acct.Deposit(20);
 *                      acct.Withdraw(10);
 *                      decimal balance = acct.GetBalance();
 *                      Console.WriteLine($"Account balance is {balance} (should be 10)");
 *                      acct.Deposit(-10);
 *                      balance = acct.GetBalance();
 *                      Console.WriteLine($"Account balance is {balance} (should be 10)");
 *                      acct.Withdraw(-10);
 *                      balance = acct.GetBalance();
 *                      Console.WriteLine($"Account balance is {balance} (should be 10)");
 *                      acct.Withdraw(20);
 *                      balance = acct.GetBalance();
 *                      Console.WriteLine($"Account balance is {balance} (should be 10)");
 */
        }
예제 #2
0
        static void Main(string[] args)
        {
            var dummy = new IDummy();
            var acct1 = new Account();

            Savings sav1 = new Savings();

            sav1.Number = "SAV001";
            sav1.Name   = "My savings account";
            sav1.ChangeRate(0.02);

            MoneyMarket mm = new MoneyMarket();

            mm.Number = "MM001";
            mm.Name   = "My money market account";
            mm.Deposit(100);
            mm.MMRate = 0.05;
            mm.PayInterest(12);

            Checking chk = new Checking();

            chk.Number = "CHK001";
            chk.Name   = "My checking account";
            chk.Deposit(100);
            chk.Pay(100, 20);

            Account[] accounts = new Account[] { sav1, mm, chk };

            foreach (Account acct in accounts)
            {
                Console.WriteLine(acct.Print());
            }


/*
 *          bool ItWorked = mm.TransferTo(sav1, 150);
 *          Console.WriteLine($"Money Market balance is {mm.GetBalance()}");
 *          Console.WriteLine($"Saving1 balance is {sav1.GetBalance()}");
 *
 *          Savings sav = new Savings();
 *          sav.Number = "1002";
 *          sav.Name = "Savings 1";
 *          sav.IntRate = 0.1;
 *
 *          sav.Deposit(200);
 *          sav.Withdraw(100);
 *          decimal interestToBePaid = sav.CalcInterest(12);
 *          sav.PayInterest(interestToBePaid);
 *          decimal savbal = sav.GetBalance();
 *          Console.WriteLine($"Savings balance is {savbal}");
 * /*
 *          Account acct = new Account();
 *          acct.Number = "1001";
 *          acct.Name = "Test Account";
 *
 *          acct.Deposit(20);
 *          acct.Withdraw(10);
 *          decimal balance = acct.GetBalance();
 *          Console.WriteLine($"Account balance is {balance} (should be 10)");
 *
 *          acct.Deposit(-10);
 *          balance = acct.GetBalance();
 *          Console.WriteLine($"Account balance is {balance} (should be 10)");
 *
 *          acct.Withdraw(-10);
 *          balance = acct.GetBalance();
 *          Console.WriteLine($"Account balance is {balance} (should be 10)");
 *
 *          acct.Withdraw(20);
 *          balance = acct.GetBalance();
 *          Console.WriteLine($"Account balance is {balance} (should be 10)");
 */
        }