示例#1
0
        static void Main(string[] args)
        {
            string errorMessage = "Invalid input";

            while (ProgramLogin.j < 2)
            {
                Console.WriteLine("Please enter 1 to login or type \"quit\" to exit : ");
                string entry = Console.ReadLine();
                if (string.Equals(entry.ToLower(), "quit"))
                {
                    System.Environment.Exit(1);
                }
                else if (string.Equals(entry, ""))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(errorMessage);
                    Console.ResetColor();
                }
                try
                {
                    int userEntry = int.Parse(entry);
                    if (userEntry == 1)
                    {
                        ProgramLogin.loginAttempt();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(errorMessage);
                        Console.ResetColor();
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(errorMessage + " Exception Handled!");
                    Console.ResetColor();
                }
                if (ProgramLogin.j == 2)    //admin user options
                {
                    AdminProfile.RunAdminProfile();
                }
                else if (ProgramLogin.j == 3)    //general user options
                {
                    UserProfile.RunUserProfile();
                }
                else if (ProgramLogin.j == 4)    //John Doe user options
                {
                    ExampleProfile.RunExampleProfile();
                }
                ProgramLogin.j = 0;
            }
        }
        public static void RunExampleProfile()
        {
            int l = 0;

            ExampleProfile.GetAccountDetails();

            while (l < 1)
            {
                Console.WriteLine("Enter 1 to transfer funds, 2 to deposit funds, 3 to logout or type \"quit\" to exit");
                string inProgramEntry = Console.ReadLine().ToLower();
                if (string.Equals(inProgramEntry, "quit"))
                {
                    System.Environment.Exit(1);
                }
                else if (string.Equals(inProgramEntry, ""))
                {
                    Console.WriteLine(errorMessage);
                }
                try
                {
                    int InProgramEntry = int.Parse(inProgramEntry);
                    if (InProgramEntry == 1)
                    {
                        ExampleProfile.TransferFunds();
                        ExampleProfile.GetAccountDetails();
                    }
                    else if (InProgramEntry == 2)
                    {
                        ExampleProfile.AddFunds();
                        ExampleProfile.GetAccountDetails();
                    }
                    else if (InProgramEntry == 3)
                    {
                        break;
                    }
                    else if (InProgramEntry == 0)
                    {
                        continue;
                    }
                    else
                    {
                        Console.WriteLine(errorMessage);
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine(errorMessage + " Exception handled!");
                }
            }
        }