Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var acct100 = new Account();
            acct100.Deposit(100);
            try
            { acct100.Withdraw(12000); }
            catch (InsufficientFundsException ex) { }
            catch (DivideByZeroException ex) { throw; }
            catch (Exception ex) { }

            var sv1 = new Savings();
            sv1.Deposit(2000);
            ///depositing to savings

            var cd10 = new CertificateOfDeposit(5000, 60);
            var accounts = new IBanking[] { sv1, cd10 };

            //displays balance in all accounts
            foreach (var acct in accounts)
            {
                Console.WriteLine($"Account balance is {acct.GetBalance()}");
            }
            var cd1 = new CertificateOfDeposit(Amount: 1000, Months: 12);
            //cd1.Deposit(1);
            //cd1.Withdraw(1);
            cd1.WithdrawDate = DateTime.Now.AddDays(-1); // yesterday
            var funds = cd1.Withdraw();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var act100 = new Account();

            act100.Deposit(-100);
            try
            {
                act100.Withdrawal(12000);
            }
            catch (InsufficientFundsException ex) { }

            catch (DivideByZeroException ex) { throw; }

            catch (Exception ex) { }  //do this one last always since first exception that is true is thrown

            var sv1 = new Savings2();

            sv1.Deposit(2000);
            var cd10     = new CertificateOfDeposit(5000, 60);
            var accounts = new IBanking[] { sv1, cd10 };

            foreach (var acct in accounts)
            {
                Console.WriteLine($"Account balance is {acct.GetBalance()}"); //need to add composition method for CD for this to work
            }



            var sav1 = new Savings();

            sav1.Deposit(1000);
            sav1.PayInterest(3);


            var acct1 = new Account();

            acct1.Deposit(500);
            acct1.Withdrawal(200);
            acct1.Withdrawal(600);
            acct1.Deposit(-400);
            Console.WriteLine($"Balance is {acct1.Balance}");

            var acct2 = new Account();

            acct1.Transfer(1000, acct2);
            Console.WriteLine($"Balance is {acct1.Balance}");
            Console.WriteLine($"Balance is {acct2.Balance}");

            var cd1 = new CertificateOfDeposit(Amount: 1000, Months: 12);

            cd1.Deposit(1);
            cd1.Withdrawal(1);
            cd1.WithdrawlDate = DateTime.Now.AddDays(-1); //yesterday
            var funds = cd1.Withdrawal();                 //no parameters sine we will withdraw everything in acocunt
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var acct100 = new Account();

            acct100.Deposit(100);
            try {
                acct100.Withdraw(12000);
            } catch (InsufficientFundsException ex) {
            } catch (DivideByZeroException ex) {
                throw;
            } catch (Exception ex) {
            }

            var sv1 = new Savings2();

            sv1.Deposit(2000);
            var cd10     = new CertificateOfDeposit2(5000, 60);
            var accounts = new IBanking[] { sv1, cd10 };

            foreach (var acct in accounts)
            {
                Console.WriteLine($"Account balance is {acct.GetBalance()}");
            }

            var cd1 = new CertificateOfDeposit2(Amount: 1000, Months: 12);

            //cd1.Deposit(1);
            //cd1.Withdraw(1);
            cd1.WithdrawDate = DateTime.Now.AddDays(-1); // yesterday
            var funds = cd1.Withdraw();

            var sav1 = new Savings();

            sav1.Deposit(1000);
            sav1.PayInterest(3);

            var acct1 = new Account();

            acct1.Deposit(500);
            acct1.Withdraw(200);
            acct1.Withdraw(600);
            acct1.Deposit(-400);
            Console.WriteLine($"Balance is {acct1.Balance}");

            var acct2 = new Account();

            acct1.Transfer(1000, acct2);
            Console.WriteLine($"Balance is {acct1.Balance}");
            Console.WriteLine($"Balance is {acct2.Balance}");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var sav2 = new Savings2();

            sav2.Deposit(2000);
            var cd1 = new CD2(Amount: 5000, Months: 60);

            var accounts = new IBanking[] { sav2, cd1 };

            var acct100 = new Account();

            acct100.Deposit(10);
            try
            {
                acct100.Withdraw(100);
            } catch (InsufficientFundsException ex)
            {
                throw;
            }



            //foreach(var i in accounts)
            //{
            //    Console.WriteLine(i.getBalance());
            //}



            //cd1.WithDate = DateTime.Now.AddDays(-1);

            //var funds = cd1.Withdraw();
            //sav2.Deposit(500);
            //sav2.InterestRate = .12m;
            //sav2.PayInterest(5);
            //Console.WriteLine();
            //acc2.Deposit(1000);
            //acc1.Deposit(500);
            //acc2.Transfer(acc1, 1100);
            //Console.WriteLine(acc1.Balance);
            //Console.WriteLine(acc2.Balance);
        }
Exemplo n.º 5
0
 public AccountController(IBanking banking, IMapper mapper)
 {
     _banking = banking;
     _mapper  = mapper;
 }