Example #1
0
        private static void CreateAccount(string[] args)
        {
            switch (GetAccountType())
            {
            case 1:
                var savingsAccount = new SavingsAccount();
                savingsAccount
                .Create(GetFirstName(), GetLastName(), GetIdNumber(), GetPay(savingsAccount.MinimumPay, args));
                var initialDeposit = InitialDeposit();
                if (initialDeposit >= savingsAccount.BookBalance)
                {
                    savingsAccount.Deposit(initialDeposit);
                    SavingsAccounts.Add(savingsAccount);
                    Console.WriteLine(savingsAccount.ToString());
                }
                else
                {
                    Console.WriteLine($"Initial deposit must be a minimum of {savingsAccount.BookBalance}");
                }

                Main(args);
                break;

            case 2:
                var currentAccount = new CurrentAccount();
                currentAccount.Create(GetFirstName(), GetLastName(), GetIdNumber(),
                                      GetPay(currentAccount.MinimumPay, args));
                currentAccount.Deposit(InitialDeposit());
                CurrentAccounts.Add(currentAccount);
                Console.WriteLine(currentAccount.ToString());
                Main(args);
                break;

            case 3:
                var platinumAccount = new PlatinumAccount();
                platinumAccount
                .Create(GetFirstName(), GetLastName(), GetIdNumber(), GetPay(platinumAccount.MinimumPay, args));
                platinumAccount.Deposit(InitialDeposit());
                PlatinumAccounts.Add(platinumAccount);
                Console.WriteLine(platinumAccount.ToString());
                Main(args);
                break;
            }
        }
        static void Main(string[] args)
        {
            CreditAccount cc = new CreditAccount();

            CreditAccount  c  = new CreditAccount("18-1", "MD Nabil Hossain", 10000);
            CurrentAccount cu = new CurrentAccount("18-2", "Fawaz Hossain", 10000);
            SavingsAccount s  = new SavingsAccount("18-3", "Famil Hossain", 10000);

            Boolean repit = true;

            while (repit)
            {
                Console.WriteLine("\n1. Show all Account details ");
                Console.WriteLine("2. Deposit ");
                Console.WriteLine("3. Withdraw ");
                Console.WriteLine("4. Exit  ");
                int option = Convert.ToInt32(Console.ReadLine());

                switch (option)
                {
                case 1:
                    c.show();
                    cu.show();
                    s.show();
                    break;

                case 2:
                    Console.WriteLine("Enter Account Number: ");
                    string AccountNumber = Console.ReadLine();
                    if (c.AccNumber == AccountNumber)
                    {
                        Console.WriteLine("Enter Depost Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        c.Deposit(balanceC);
                    }
                    else if (cu.AccNumber == AccountNumber)
                    {
                        Console.WriteLine("Enter Depost Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        cu.Deposit(balanceC);
                    }
                    else if (s.AccNumber == AccountNumber)
                    {
                        Console.WriteLine("Enter Fixed Depost Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        s.Deposit(balanceC);
                    }
                    else
                    {
                        Console.WriteLine("Invalid Account .");
                    }

                    break;

                case 3:
                    Console.WriteLine("Enter Account Number: ");
                    string AccountNumberW = Console.ReadLine();
                    if (c.AccNumber == AccountNumberW)
                    {
                        Console.WriteLine("Enter Withdraw Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        c.Withdraw(balanceC);
                    }
                    else if (cu.AccNumber == AccountNumberW)
                    {
                        Console.WriteLine("Enter Withdraw Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        cu.Withdraw(balanceC);
                    }
                    else if (s.AccNumber == AccountNumberW)
                    {
                        Console.WriteLine("Enter Withdraw Blance:");
                        Double balanceC = Convert.ToDouble(Console.ReadLine());
                        s.Withdraw(balanceC);
                    }
                    else
                    {
                        Console.WriteLine("Invalid Account .");
                    }

                    break;

                case 4:
                    Console.WriteLine("Exit ");
                    repit = false;
                    break;

                default:
                    Console.WriteLine("Invalid Input");
                    break;
                }
            }
        }