static void Main(string[] args)
        {
            Console.WriteLine("Welcome to NUSISS bank.");
            Console.WriteLine("Please select your account type : \n 1. Savings Account \n 2. Current Account \n 3. OverDraft Account ");
            int selectedOption = Convert.ToInt32(Console.ReadLine());


            Console.WriteLine("Please enter your Bank Account Id: ");
            string bAcctId = Console.ReadLine();

            Console.WriteLine("Please enter your Bank Account number: ");
            int aNumber = Convert.ToInt32(Console.ReadLine());


            if (selectedOption == 1)
            {
                Workshop_05_1_BankAccount_Polymorphism_SavingAccount savingAcct = new Workshop_05_1_BankAccount_Polymorphism_SavingAccount(bAcctId, aNumber);
                savingAcct.SetBalance(5000.00);

                Console.WriteLine($"Your saving account {aNumber} current balance is $ {savingAcct.GetBalance():0.00}. \n");

                savingAcct.TestBalance();
                savingAcct.CalculateInterest(1.00);
                savingAcct.CreditInterest();

                Console.WriteLine($"Interest earned = ${savingAcct.interestEarned:0.00}");
                Console.WriteLine($"Total Amount in saving account with interest = ${savingAcct.GetBalance():0.00}");
            }
            else if (selectedOption == 2)

            {
                Workshop_05_1_BankAccount_Polymorphism_CurrentAccount currentAcct = new Workshop_05_1_BankAccount_Polymorphism_CurrentAccount(bAcctId, aNumber);
                currentAcct.SetBalance(2000.00);

                Console.WriteLine($"Your current account {aNumber} current balance is $ {currentAcct.GetBalance():0.00}. \n");

                currentAcct.TestBalance();
                currentAcct.CalculateInterest(0.25);
                currentAcct.CreditInterest();

                Console.WriteLine($"Interest earned = ${currentAcct.interestEarned:0.00}");
                Console.WriteLine($"Total amount in current account with interest = ${currentAcct.GetBalance():0.00}");
            }
            else if (selectedOption == 3)
            {
                Workshop_05_1_BankAccount_Polymorphism_OverDraftAccount oDAcct = new Workshop_05_1_BankAccount_Polymorphism_OverDraftAccount(bAcctId, aNumber);
                oDAcct.SetBalance(-90);

                Console.WriteLine($"Your over-draft account {aNumber} current balance is $ {oDAcct.GetBalance():0.00}. \n");

                oDAcct.TestBalance();
                oDAcct.CalculateInterest(0.25);
                oDAcct.CreditInterest();

                Console.WriteLine("Your account is negative, no interest is earned. ");
                Console.WriteLine($"Please pay $ {-oDAcct.interestPaid: 0.00} as administrative fees for negative balance.");
                Console.WriteLine($"Total amount owe to over-draft account (with interest) = $ {- oDAcct.GetBalance(): 0.00}");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine(" Welcome to NUSISS Bank Staff Intranet.");
            Console.WriteLine(" Please key in a bank branch name: ");
            string bName = Console.ReadLine();

            Console.WriteLine(" Please key your username: "******"Tom001", 1001);

            savingAcct01.SetBalance(4000.00);
            savingAcct01.Deposit(800.00);
            savingAcct01.TestBalance();
            savingAcct01.CalculateInterest(1.00);
            savingAcct01.CreditInterest();

            // create a current account
            Workshop_05_1_BankAccount_Polymorphism_CurrentAccount currentAcct01 = new Workshop_05_1_BankAccount_Polymorphism_CurrentAccount("Karen002", 2001);

            currentAcct01.SetBalance(6000.00);
            currentAcct01.Deposit(5000.00);
            currentAcct01.TestBalance();
            currentAcct01.CalculateInterest(0.25);
            currentAcct01.CreditInterest();

            // create an over-draft account
            Workshop_05_1_BankAccount_Polymorphism_OverDraftAccount oDAcct01 = new Workshop_05_1_BankAccount_Polymorphism_OverDraftAccount("Ken003", 3001);

            oDAcct01.SetBalance(-100.00);
            oDAcct01.TestBalance();
            oDAcct01.CalculateInterest(0.25);
            oDAcct01.CreditInterest();

            // create a bank branch
            // then, add all the accounts created above into the list of bank accounts belonging to the bank branch
            Workshop_05_2_BankBranch branch01 = new Workshop_05_2_BankBranch(bName, mName);

            branch01.AddAccount(savingAcct01);
            branch01.AddAccount(currentAcct01);
            branch01.AddAccount(oDAcct01);

            // actions of the bank branch
            branch01.PrintCustomers();
            branch01.TotalDeposits();
            branch01.TotalInterestPaid();
            branch01.TotalInterestEarned();
        }