コード例 #1
0
        static void Main(string[] args)
        {
            List <BankAccount> bankAccounts = new List <BankAccount>();
            BankAccount        account      = new BankAccount();

            account.AccountNo    = "AC-001";
            account.CustomerName = "Sharif";
            account.Deposit(15000);
            SavingAccount sv1 = new SavingAccount();

            sv1.AccountNo    = "AC-002";
            sv1.CustomerName = "Mohammad";
            sv1.Deposit(10000);
            sv1.Withdraw(8000);
            CheckingAccount chk1 = new CheckingAccount();

            chk1.AccountNo    = "AC-003";
            chk1.CustomerName = "Aabduallah";
            chk1.Withdraw(15000);
            bankAccounts.Add(account);
            bankAccounts.Add(sv1);
            bankAccounts.Add(chk1);
            //foreach (BankAccount account in bankAccounts)
            //{
            //    Console.WriteLine();
            //}
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wohhie/BITM
        static void Main(string[] args)
        {
            Console.WriteLine("Bank Account System.");
            //SavingAccount savingAccount1 = new SavingAccount();
            SavingAccount savingAccount1 = new SavingAccount("SV-101", "Sakib Khan", 1000);

            //savingAccount1.AccountNumber = "SV-101";
            //savingAccount1.CustomerName = "Sakib Khan";
            Console.WriteLine(savingAccount1.Deposit(1000));
            Console.WriteLine(savingAccount1.Withdraw(1500));
            Console.WriteLine(savingAccount1.Balance);


            Console.WriteLine("-------------------------------------");

            CheckingAccount checkingAccount1 = new CheckingAccount("CK - 120", "Sarif Khan", 500);

            Console.WriteLine(checkingAccount1.Deposit(1000));
            Console.WriteLine(checkingAccount1.Withdraw(40000));
            Console.WriteLine(checkingAccount1.Balance);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Client          mem   = new Client();
            CheckingAccount check = new CheckingAccount();
            SavingAccount   save  = new SavingAccount();
            int             input;

            do
            {
                Console.WriteLine("\nView Client Informatin: Select 1");
                Console.WriteLine("View Account Balance: select 2");
                Console.WriteLine("Deposit Funds select 3");
                Console.WriteLine("Withdraw Fund Select 4");
                Console.WriteLine("Exit select 5");



                input = int.Parse(Console.ReadLine());

                switch (input)
                {
                case 1:
                    mem.ClientInfo();
                    break;

                case 2:
                    Console.WriteLine("Checking Account Select 1\n Savings Account select 2");
                    int acc;
                    acc = int.Parse(Console.ReadLine());

                    switch (acc)
                    {
                    case 1:

                        Console.WriteLine("\nChecking account Balance amount:" + check.BalanceAmount());
                        break;

                    case 2:
                        Console.WriteLine("\nSaving account Balance amount:" + save.BalanceAmount());
                        save.BalanceAmount();
                        break;

                    default:
                        break;
                    }
                    break;



                case 3:
                    Console.WriteLine("Checking Account Select 1\n Savings Account select 2");
                    int acc1;
                    acc1 = int.Parse(Console.ReadLine());

                    switch (acc1)
                    {
                    case 1:
                        Console.WriteLine("enter the amount to deposit");
                        int amount = int.Parse(Console.ReadLine());
                        check.Deposit(amount);
                        break;

                    case 2:
                        Console.WriteLine("enter the amount to deposit");
                        int amount1 = int.Parse(Console.ReadLine());
                        save.Deposit(amount1);
                        break;

                    default:
                        break;
                    }
                    break;

                case 4:
                    Console.WriteLine("Checking Account Select 1\n Savings Account select 2");
                    int acc2;
                    acc2 = int.Parse(Console.ReadLine());

                    switch (acc2)
                    {
                    case 1:
                        Console.WriteLine("enter the amount to withdraw");
                        int amount = int.Parse(Console.ReadLine());
                        check.Withdraw(amount);
                        break;

                    case 2:
                        Console.WriteLine("enter the amount to Withdraw");
                        int amount1 = int.Parse(Console.ReadLine());
                        save.Withdraw(amount1);
                        break;

                    default:
                        break;
                    }
                    break;

                case 5:
                    Console.WriteLine("Signed Out");
                    break;
                }
            } while (input != 5);
        }
コード例 #4
0
        private void btnSavingsAccount_Click(object sender, EventArgs e)
        {
            //// create account with vaild values
            //SavingsAccount b1 = new SavingsAccount(123, 100, "Savings Account", 0.05m);
            SavingAccount b1 = new SavingAccount(123, 100, "Saving Account", 0.05m);

            //// test get accessors
            //string display = "Testing Get Accessors for Savings Account: " +
            //                 "\nClient Name: " + b1.ClientName +
            //                 "\nAccount Number: " + b1.AccountNumber +
            //                 "\nDate Open: " + b1.DateOpen +
            //                 "\nBalance: " + b1.Balance +
            //                 "\nInterest: " + b1.Interest;
            string Display = "Testing Get Accessors for Savings Account: " +
                             "\nClient Name: " + b1.ClientName +
                             "\nAccount Number: " + b1.AccountNumber +
                             "\nDate Open: " + b1.DateOpen +
                             "\nBalance: " + b1.Balance +
                             "\nInterest: " + b1.Interest;

            //// test set accessors - valid data
            b1.ClientName = "J Doe";

            b1.Interest = 0.06m;
            Display    += "\n\nTest Set Accessors: Name = J Doe, Interest = 0.06" +
                          "\nNew Name: " + b1.ClientName +
                          "\nNew Interest: " + b1.Interest;

            //// test set accessors - invalid data
            b1.ClientName = "";
            b1.Interest   = 5;
            Display      += "\n\nTest Set Accessors: Name = null, Interest = 5" +
                            "\nNew Name: " + b1.ClientName +
                            "\nNew Interest: " + b1.Interest;

            //// test ToString() method
            Display += "\n\nToString():\n" + b1.ToString();

            //// test Deposit method
            decimal deposit = b1.Deposit(20m);

            Display += "\n\nDeposit $20, Deposit: " + deposit;
            deposit  = b1.Deposit(-30m);
            Display += "\nDeposit -$30, Deposit: " + deposit +
                       "\nBalance: " + b1.Balance;

            //// test Withdraw method
            decimal withdraw = b1.Withdraw(20m);

            Display += "\n\nWithdraw $20, Withdraw: " + withdraw;
            withdraw = b1.Withdraw(-30m);
            Display += "\nWithdraw -$30, Withdraw: " + withdraw +
                       "\nBalance: " + b1.Balance;

            //// test ApplyMonthlyInterest method
            Display += "\n\nBalance Before Interest: " + b1.Balance;
            decimal interest = b1.ApplyMonthlyInterest();

            Display += "\nInterest Earned: " + interest +
                       "\nNew Balance: " + b1.Balance;

            MessageBox.Show(Display, BankAccount.BankName);
        }