Example #1
0
        // Main logic hub of the program, stuff branches out from here
        private bool EventLoop()
        {
            ConsoleMenuPainter.TextColor();
            bool finished = false;

            do
            {
                string[] menuItems = new string[] {
                    "1) Generate male names",
                    "2) Generate female names",
                    "3) Generate male and female names",
                    "4) Quit"
                };
                Console.Clear();
                Output.Intro();
                int userChoice = Menu.Selection(menuItems, 0, 12); // the two digits are to place the menu on the x and y axis

                if (userChoice == 3)
                {
                    Console.Clear();
                    Console.WriteLine("Quit");
                    finished = true;
                }
                else
                {
                    GenerateNames(userChoice);
                }
            } while (!finished);

            return(finished);
        }
Example #2
0
 private void PrintNames()
 {
     foreach (var name in outputListOfNames)
     {
         ConsoleMenuPainter.TextColor();
         Console.WriteLine(name);
     }
 }
Example #3
0
        //Intro text tells the user what this program does
        internal static void Intro()
        {
            ConsoleMenuPainter.TextColor();

            Console.WriteLine("Welcome, this is a simple Random Name Generator.\n\nIt gets the last names from the 2010 census.");
            Console.WriteLine("We are only using the last names that show up at least once in \n" +
                              "every 100,000 people you would likely meet in the United States.\n");
            Console.WriteLine("For the first and middle names I am using data from the Social Security Administration for the \n" +
                              "birth year of 2018 (the latest available at the time the program was written.\n\n" +
                              "What would you like to do? (Make your selection with the \n" +
                              "arrow or number key and then hit enter)");
        }
Example #4
0
        // After the names have been generated, what does the user want to do with them?
        private void NowWhat()
        {
            ConsoleMenuPainter.TextColor();
            bool finished = false;

            do
            {
                Console.Clear();
                Console.WriteLine($"OK, I've generated all {outputListOfNames.Count} names.");
                Console.WriteLine("What would you like to do?\n");
                int userChoice = Elicit.WhatNowMenu(0, 5); // the two digits are to place the menu on the x and y axis

                switch (userChoice)
                {
                case 0:
                    Console.Clear();
                    Console.WriteLine("Print the names to the screen\n");
                    PrintNames();
                    Console.WriteLine("\n\nHit enter to continue");
                    Console.ReadLine();
                    finished = true;
                    break;

                case 1:
                    Console.Clear();
                    Console.WriteLine("Print the names to a file\n");
                    FileStuff.WriteToFile(outputListOfNames, "ListOfNames.txt");
                    finished = true;
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine("Both\n");
                    PrintNames();
                    FileStuff.WriteToFile(outputListOfNames, "ListOfNames.txt");
                    finished = true;
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine("Quit");
                    Console.ResetColor();
                    finished = true;
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("Default case");
                    finished = true;
                    break;
                }
            } while (!finished);
        }
Example #5
0
        private void GenerateNames(int userChoice)
        {
            Console.Clear();
            ConsoleMenuPainter.TextColor();
            int  numberOfNames;
            bool middleNames;

            switch (userChoice)
            {
            case 0:
                Console.Clear();
                Console.WriteLine("Generate Male Names\n");
                (numberOfNames, middleNames) = GetNumberAndMiddleNameInput();
                outputListOfNames            = Rand.ListOfNames(numberOfNames, firstNamesMale, lastNames, outputListOfNames, middleNames);
                NowWhat();
                break;

            case 1:
                Console.Clear();
                Console.WriteLine("Generate Female Names\n");
                (numberOfNames, middleNames) = GetNumberAndMiddleNameInput();
                outputListOfNames            = Rand.ListOfNames(numberOfNames, firstNamesFemale, lastNames, outputListOfNames, middleNames);
                NowWhat();
                break;

            case 2:
                Console.Clear();
                Console.WriteLine("Generate Male and Female Names\n");
                (numberOfNames, middleNames) = GetNumberAndMiddleNameInput();
                outputListOfNames            = Rand.MaleAndFemaleNames(numberOfNames, firstNamesMale, firstNamesFemale, lastNames, outputListOfNames, middleNames);
                NowWhat();
                break;

            default:
                Console.Clear();
                Console.WriteLine("Default case");
                break;
            }
        }