Example #1
0
        public static bool Loggingin(BankingAccount account, List <string> Login, string selection, string username = "", string password = "")
        {
            do
            {
                Console.Clear();
                PrintMenus(Login, selection);

                Console.Write("Enter Username: "******"Enter Password: "******"" || password == "");

            bool[] validation = account.ValidatePassword(username, password);

            if (validation[0] == true && validation[1] == true)
            {
                return(true);
            }
            else if (validation[0] == true && validation[1] == false)
            {
                Console.WriteLine("invalid password, try again");
                Loggingin(account, Login, selection);
            }
            else if (validation[0] == false && validation[1] == true)
            {
                Console.WriteLine("invalid username, try again");
                Loggingin(account, Login, selection);
            }
            else if (validation[0] == false && validation[1] == false)
            {
                Console.WriteLine("invalid, try again");
                Loggingin(account, Login, selection);
            }
            return(true);
        }
Example #2
0
        static void Main(string[] args)
        {
            BankingAccountApp();

            List <string> Login   = new List <string>();
            List <string> Banking = new List <string>();

            string loginSelection = LoginMenu(Login);

            BankingAccount account = new BankingAccount(null, null, null);

            if (loginSelection.Contains("(C)"))
            {
                Console.WriteLine();
                Console.CursorVisible = true;

                account = new BankingAccount();
            }
            else if (loginSelection.Contains("(L)"))
            {
                account = new BankingAccount("Lee", "abc", 1000.00);
            }

            Console.WriteLine();
            Console.CursorVisible = true;

            bool success;

            do
            {
                success = Loggingin(account, Login, loginSelection);
            } while (success == false);

            Console.CursorVisible = true;
            ConsoleColor reset   = Console.ForegroundColor;
            ConsoleColor warning = ConsoleColor.Red;

            string bankingSelection;

            do
            {
                bankingSelection = BankingMenu(Login, loginSelection, Banking);

                if (bankingSelection.Contains("(D)"))
                {
                    Console.CursorVisible = true;

                    int           i = 0;
                    double        value;
                    string        responce;
                    List <string> warningText = new List <string>();
                    warningText.Add("Invalid, try again");

                    bool parsed;
                    do
                    {
                        do
                        {
                            Console.SetCursorPosition(0, 2);
                            Console.WriteLine();
                            Console.Write("Enter Deposit Amount: $");

                            if (i > 0)
                            {
                                Console.CursorVisible = false;
                                Console.SetCursorPosition(0, 2);
                                System.Threading.Thread.Sleep(2000);
                                warningText[0].Replace(warningText[0], Print("                   "));
                                Console.SetCursorPosition(23, 3);
                                Console.CursorVisible = true;
                            }

                            responce = Console.ReadLine();
                        } while (responce == null);

                        parsed = double.TryParse(responce, out value);
                        if (parsed)
                        {
                            account.Deposit(value);
                        }
                        else
                        {
                            Console.Clear();

                            PrintMenus(Login, loginSelection, Banking, bankingSelection);
                            Console.WriteLine();

                            Console.ForegroundColor = warning;
                            Console.Write(warningText[0]);
                            Console.ForegroundColor = reset;
                            i++;
                        }
                    } while (parsed == false);
                }
                else if (bankingSelection.Contains("(W)"))
                {
                    Console.CursorVisible = true;

                    int           i = 0;
                    double        value;
                    string        responce;
                    List <string> warningText = new List <string>();
                    warningText.Add("Invalid, try again");

                    bool parsed;
                    do
                    {
                        do
                        {
                            Console.SetCursorPosition(0, 2);
                            Console.WriteLine();
                            Console.Write("Enter Withdraw Amount: $");

                            if (i > 0)
                            {
                                Console.CursorVisible = false;
                                Console.SetCursorPosition(0, 2);
                                System.Threading.Thread.Sleep(2000);
                                warningText[0].Replace(warningText[0], Print("                   "));
                                Console.SetCursorPosition(24, 3);
                                Console.CursorVisible = true;
                            }

                            responce = Console.ReadLine();
                        } while (responce == null);

                        parsed = double.TryParse(responce, out value);
                        if (parsed)
                        {
                            account.Withdraw(value);

                            if (account.Balance < 0 && value > 0)
                            {
                                Console.WriteLine();
                                Console.ForegroundColor = warning;
                                Console.Write("Over Draft Charge of $10");
                                Console.ForegroundColor = reset;
                                System.Threading.Thread.Sleep(2000);
                                account.Withdraw(10.00);
                            }
                        }
                        else
                        {
                            Console.Clear();

                            PrintMenus(Login, loginSelection, Banking, bankingSelection);
                            Console.WriteLine();

                            Console.ForegroundColor = warning;
                            Console.Write(warningText[0]);
                            Console.ForegroundColor = reset;
                            i++;
                        }
                    } while (parsed == false);
                }
                else if (bankingSelection.Contains("(B)"))
                {
                    Console.SetCursorPosition(0, 2);
                    Console.WriteLine();
                    Console.Write(account.ToString());
                    System.Threading.Thread.Sleep(2000);
                }
            } while (!bankingSelection.Contains("(E)"));

            if (bankingSelection.Contains("(E)"))
            {
                Console.SetCursorPosition(0, 2);
                Console.WriteLine();
                Console.Write(account.ToString());
                System.Threading.Thread.Sleep(2000);
            }
        }