Пример #1
0
        static void Main(string[] args)
        {
            var cust1 = new Customer();

            cust1.Name = "New Customer";

            var sav1 = new Savings(0.02m, "My Primary Savings", cust1);

            sav1.Deposit(120);
            sav1.Withdraw(20);
            Console.WriteLine($"Savv1 Balance is {sav1.GetBalance()}");
            //var interst = sav1.CalcInterest(6);
            //sav1.Deposit(interst);
            sav1.CalcAndPayInterest(6);                                               // combining the top two steps
            Console.WriteLine($"Savv1 Balance is {sav1.GetBalance().ToString("C")}"); // .ToString("C") after value will print as two decimel with dollar sign
            Console.WriteLine(sav1.Print());

            var chk1 = new Checking("First Checking", cust1);

            chk1.Deposit(200);
            Console.WriteLine(chk1.Print());

            /// This will no longer work because we set Account class to "abstract"
            ////var acct1 = new Account("Primary Checking", cust1);
            ////acct1.Deposit(2);
            //////Console.WriteLine($"{acct1.AccountNumber} {acct1.Description} "
            //////    + $" {acct1.GetBalance()} {acct1.CustomerInstance.Name}");
            ////Console.WriteLine(acct1.Print());

            ////var acct2 = new Account("Secondary Checking", cust1);
            ////acct2.Deposit(1000);
            //////Console.WriteLine($"{acct2.AccountNumber} {acct2.Description} "
            //////    + $" {acct2.GetBalance()} {acct2.CustomerInstance.Name}");

            ////cust1.Name = "1st Customer";

            ////var acct3 = new Account("Primary Savings", cust1);
            ////acct3.Deposit(50000);
            //////Console.WriteLine($"{acct3.AccountNumber} {acct3.Description} "
            //////    + $" {acct3.GetBalance()} {acct3.CustomerInstance.Name}");

            var accounts     = new Account[] { acct1, acct2, acct3 };
            var accountTotal = 0M;

            foreach (var account in accounts)
            {
                accountTotal += account.GetBalance();
                Console.WriteLine($"{account.AccountNumber} {account.Description} "
                                  + $" {account.GetBalance()} {account.CustomerInstance.Name}");
            }
            Console.WriteLine($"Total of all account is {accountTotal}");
        }
Пример #2
0
        static void Main(string[] args)
        {
            var cust1 = new Customer();  //use default constructor

            cust1.Name = "New Customer"; //creates new Customer

            var sav1 = new Savings(0.02m, "My Primary Savings", cust1);

            sav1.Deposit(120);
            sav1.Withdraw(20);
            Console.WriteLine($"Sav1 blalance is {sav1.GetBalance()}");
            sav1.CalcAndPayInterest(6);
            Console.WriteLine($"Sav1 blalance after interest is {sav1.GetBalance().ToString("C")}");
            Console.WriteLine(sav1.Print());

            var chk1 = new Checking("First Checking", cust1);

            chk1.Deposit(200);
            Console.WriteLine(chk1.Print());


            var acct1 = new Account("Primary Checking", cust1);

            acct1.Deposit(2);
            Console.WriteLine(acct1.Print());


            var acct2 = new Account("Secondary Checking", cust1); //passthrough customer 1 to constructor

            acct2.Deposit(1000);

            cust1.Name = "1st Customer";  // change customer name

            var acct3 = new Account("Primary Savings", cust1);

            acct3.Deposit(50000);


            var accounts     = new Account[] { acct1, acct2, acct3 }; //create an array of accounts. collection of account instances
            var accountTotal = 0M;

            foreach (var account in accounts)         //copy acct1, process, copy acct2 proceses...
            {
                accountTotal += account.GetBalance(); //gets account balance, adds to total
                Console.WriteLine($"{account.AccountNumber} {account.Description} "
                                  + $"{account.GetBalance()} {account.CustomerInstance.Name}");
            }
            Console.WriteLine($"Total of all account is {accountTotal}");
        }
Пример #3
0
        static void Main(string[] args)
        {
            var cust1 = new Customer();

            cust1.Name = "New Customer";

            var sav1 = new Savings(0.02M, "My Primary Savings", cust1);

            sav1.Deposit(120);
            sav1.Withdraw(20);
            Console.WriteLine($"Sav1 balance is {sav1.GetBalance()}");
            sav1.CalcAndPayInterest(6);
            Console.WriteLine($"Sav1 balance after interest is {sav1.GetBalance().ToString("C")}");
            Console.WriteLine(sav1.Print());

            var chk1 = new Checking("First checking", cust1);

            chk1.Deposit(50000);
            Console.WriteLine(chk1.Print());

            var acct1 = new Account("Primary Checking", cust1);

            acct1.Deposit(2);
            Console.WriteLine(acct1.Print());



            //var acct2 = new Account("Secondary", cust1);
            //acct2.Deposit(1000);



            //cust1.Name = "1st Customer";

            //var acct3 = new Account("Primary Savings", cust1);
            //acct3.Deposit(50000);

            //var accounts = new Account [] { acct1, acct2, acct3 };
            //var accountTotal = 0M;
            //foreach (var account in accounts) {
            //    accountTotal += account.GetBalance();
            //    Console.WriteLine($"{account.AccountNumber} {account.Description} " +
            //  $"{account.GetBalance()} {account.CustomerInstance.Name}");

            //}
            //Console.WriteLine($"Total of all Accounts is {accountTotal}");
        }
Пример #4
0
        static void Main(string[] args)
        {
            var cust1 = new Customer("CocaCola", "Cincinnati", "OH");
            var acct1 = new Account("Primary Checking", cust1);

            Console.WriteLine($"{cust1.Name}, {cust1.City}, {cust1.State}, ${cust1.Sales}, {cust1.Active}, Id - {cust1.Id}");

            cust1.CheckSales();
            cust1.AddSales(200);
            cust1.ChangeName("Coke");

            var sav1 = new Savings(0.12m, "My primary savings", cust1);

            sav1.Deposit(120);
            sav1.Withdraw(20);
            Console.WriteLine($"Sav1 balance is {sav1.GetBalance()}");
            var interest = sav1.CalcInterest(6);

            Console.WriteLine($"interest is {interest}");
            sav1.Deposit(interest);
            Console.WriteLine(sav1.Print());
            Console.WriteLine(acct1.Print());
            Console.WriteLine();

            var chk1 = new Checking("First Checking", cust1);

            chk1.Deposit(200);
            Console.WriteLine(chk1.Print());

            //Console.WriteLine();

            //var cust2 = new Customer("Ikea", "Tampa", "FL");
            //var acct2 = new Account("Money Laundering", cust2);
            //var acct3 = new Account("Swear Jar", cust1);
            //Console.WriteLine($"{cust2.Name}, {cust2.City}, {cust2.State}, ${cust2.Sales}, {cust2.Active}, Id - {cust2.Id}");
            //Console.WriteLine($"{acct1.CustomerInstance.Name}------");
            //Console.WriteLine($"{acct3.CustomerInstance.Name}------");

            //cust2.ChangeLoc("Atlantis", "NM");
            //cust2.ChangeActive(false);
            //cust1.ChangeActive(true);

            //var cust3 = new Customer();
            //Console.WriteLine($"{cust3.Name}, {cust3.City}, {cust3.State}, ${cust3.Sales}, {cust3.Active}, Id - {cust3.Id}"); //Id and defaults still work



            //cust1.Name = "Playdoh";

            //var acct4 = new Account("Primary Savings", cust1);

            //acct1.Deposit(2);
            //acct3.Deposit(1000);
            //acct4.Deposit(50000);

            //var accounts = new Account[] { acct1, acct3, acct4 };
            //var accountTotal = 0m;
            //foreach(var account in accounts) {
            //    accountTotal += account.GetBalance();
            //    Console.WriteLine($"{account.Id} {account.Description} {account.CustomerInstance.Name} {account.GetBalance()}");
            //}
            //Console.WriteLine($"Total of all accounts is {accountTotal}.");


            /*
             * var acct1 = new Account("Primary Checking");
             * //acct1.Balance = 1000000m; //should not be allowed to do this without calling a method. Safety nets.
             *
             * Console.WriteLine($"{acct1.Description} account - {acct1.Id} has a balance of {acct1.GetBalance()}.");
             *
             * acct1.Deposit(1000);
             * Console.WriteLine($"{acct1.Description} account - {acct1.Id} has a balance of {acct1.GetBalance()}.");
             *
             * acct1.Withdraw(5000);
             * Console.WriteLine($"{acct1.Description} account - {acct1.Id} has a balance of {acct1.GetBalance()}.");
             *
             * var balance = acct1.GetBalance();
             * Console.WriteLine(balance);
             *
             * acct1.Withdraw(-1000000);
             * Console.WriteLine($"{acct1.Description} account - {acct1.Id} has a balance of {acct1.GetBalance()}.");
             *
             *
             * var acct2 = new Account("Secondary Checking");
             * Console.WriteLine($"{acct2.Description} account - {acct2.Id} has a balance of {acct2.GetBalance()}.");
             *
             * acct1.Transfer(acct2, 2000);
             * Console.WriteLine($"{acct2.Description} account - {acct2.Id} has a balance of {acct2.GetBalance()}.");
             *
             * acct2.Deposit(5);
             * Console.WriteLine($"{acct2.Description} account - {acct2.Id} has a balance of {acct2.GetBalance()}.");
             * Console.WriteLine($"{acct1.Description} account - {acct1.Id} has a balance of {acct1.GetBalance()}.");
             */
        }