Пример #1
0
        public MenuOption MainMenu()
        {
            ConsoleUtil.HeaderText = "The Travelling Salesman";
            ConsoleUtil.DisplayReset();
            MenuOption userMenuChoice = MenuOption.None;
            bool       usingMenu      = true;

            while (usingMenu)
            {
                int selection = MenuHandler.ChoiceSelectionCursor("Move the cursor with arrow keys and press enter to accept", "SetupAccount", "LoadAccount", "Exit");
                ConsoleUtil.DisplayReset();
                switch (selection)
                {
                case 1:
                    //Initial Salesperson account
                    userMenuChoice = MenuOption.SetupAccount;
                    usingMenu      = false;
                    break;

                case 2:
                    //Start Off From A Save File
                    userMenuChoice = MenuOption.StartFromSave;
                    usingMenu      = false;
                    break;

                case 3:
                    userMenuChoice = MenuOption.Exit;
                    usingMenu      = false;
                    break;

                default:
                    ConsoleUtil.DisplayMessage("Please.... just tell me how you did it....");
                    usingMenu = false;
                    break;
                }
            }

            return(userMenuChoice);
        }
Пример #2
0
        /// <summary>
        /// get the menu choice from the user
        /// </summary>

        public MenuOption DisplayGetUserMenuChoice()
        {
            MenuOption userMenuChoice = MenuOption.None;
            bool       usingMenu      = true;

            ConsoleUtil.HeaderText = "Main Menu";
            ConsoleUtil.DisplayReset();

            while (usingMenu)
            {
                //
                // set up display area
                //
                ConsoleUtil.DisplayReset();
                Console.CursorVisible = false;

                //
                // display the menu
                //
                ConsoleUtil.DisplayMessage("Please type the number of your menu choice.");
                ConsoleUtil.DisplayMessage("");
                Console.Write(
                    "\t" + "1. Setup Account" + Environment.NewLine +
                    "\t" + "2. Update Account Info" + Environment.NewLine +
                    "\t" + "3. Travel" + Environment.NewLine +
                    "\t" + "4. Display Cities" + Environment.NewLine +
                    "\t" + "5. Display Account Info" + Environment.NewLine +
                    "\t" + "6. Buy" + Environment.NewLine +
                    "\t" + "7. Sell" + Environment.NewLine +
                    "\t" + "8. Display Inventory" + Environment.NewLine +
                    "\t" + "9. Save Account Info" + Environment.NewLine +
                    "\t" + "0. Load Account Info" + Environment.NewLine +
                    "\t" + "E. Exit" + Environment.NewLine);


                //
                // get and process the user's response
                // note: ReadKey argument set to "true" disables the echoing of the key press
                //
                ConsoleKeyInfo userResponse = Console.ReadKey(true);
                switch (userResponse.KeyChar)
                {
                case '1':
                    userMenuChoice = MenuOption.SetupAccount;
                    usingMenu      = false;
                    break;

                case '2':
                    userMenuChoice = MenuOption.UpdateAccountInfo;
                    usingMenu      = false;
                    break;

                case '3':
                    userMenuChoice = MenuOption.Travel;
                    usingMenu      = false;
                    break;

                case '4':
                    userMenuChoice = MenuOption.DisplayCities;
                    usingMenu      = false;
                    break;

                case '5':
                    userMenuChoice = MenuOption.DisplayAccountInfo;
                    usingMenu      = false;
                    break;

                case '6':
                    userMenuChoice = MenuOption.Buy;
                    usingMenu      = false;
                    break;

                case '7':
                    userMenuChoice = MenuOption.Sell;
                    usingMenu      = false;
                    break;

                case '8':
                    userMenuChoice = MenuOption.DisplayInventory;
                    usingMenu      = false;
                    break;

                case '9':
                    userMenuChoice = MenuOption.SaveAccountInfo;
                    usingMenu      = false;
                    break;

                case '0':
                    userMenuChoice = MenuOption.LoadAccountInfo;
                    usingMenu      = false;
                    break;

                case 'E':
                case 'e':
                    userMenuChoice = MenuOption.Exit;
                    usingMenu      = false;
                    break;

                default:
                    ConsoleUtil.DisplayMessage(
                        "It appears you have selected an incorrect choice." + Environment.NewLine +
                        "Press any key to continue or the ESC key to quit the application.");

                    userResponse = Console.ReadKey(true);
                    if (userResponse.Key == ConsoleKey.Escape)
                    {
                        usingMenu = false;
                    }
                    break;
                }
            }
            Console.CursorVisible = true;

            return(userMenuChoice);
        }
Пример #3
0
        public MenuOption DisplayGetUserMenuChoice()
        {
            MenuOption userMenuChoice = MenuOption.None;
            bool       usingMenu      = true;

            while (usingMenu)
            {
                ConsoleUtil.DisplayReset();
                Console.CursorVisible = false;


                ConsoleUtil.DisplayMessage("Please type the number of your menu choice.");
                ConsoleUtil.DisplayMessage("");
                Console.Write(
                    "\t" + "1. Travel" + Environment.NewLine +
                    "\t" + "2. Buy" + Environment.NewLine +
                    "\t" + "3. Sell" + Environment.NewLine +
                    "\t" + "4. Display Inventory" + Environment.NewLine +
                    "\t" + "5. Display Cities" + Environment.NewLine +
                    "\t" + "6. Display Account Info" + Environment.NewLine +
                    "\t" + "E. Exit" + Environment.NewLine);


                ConsoleKeyInfo userResponse = Console.ReadKey(true);
                switch (userResponse.KeyChar)
                {
                case '1':
                    userMenuChoice = MenuOption.Travel;
                    usingMenu      = false;
                    break;

                case '2':
                    userMenuChoice = MenuOption.Buy;
                    usingMenu      = false;
                    break;

                case '3':
                    userMenuChoice = MenuOption.Sell;
                    usingMenu      = false;
                    break;

                case '4':
                    userMenuChoice = MenuOption.DisplayInventory;
                    usingMenu      = false;
                    break;

                case '5':
                    userMenuChoice = MenuOption.DisplayCities;
                    usingMenu      = false;
                    break;

                case '6':
                    userMenuChoice = MenuOption.DisplayAccountInfo;
                    usingMenu      = false;
                    break;

                case 'E':
                case 'e':
                    userMenuChoice = MenuOption.Exit;
                    usingMenu      = false;
                    break;

                default:
                    ConsoleUtil.DisplayMessage(
                        "It appears you have selected an incorrect choice." + Environment.NewLine +
                        "Press any key to continue or the ESC key to quit the application.");

                    userResponse = Console.ReadKey(true);
                    if (userResponse.Key == ConsoleKey.Escape)
                    {
                        usingMenu = false;
                    }
                    break;
                }
            }
            Console.CursorVisible = true;

            return(userMenuChoice);
        }
        // Display Account Edit screen
        public MenuOption DisplayGetAccountInfoToEdit()
        {
            MenuOption userMenuChoice = MenuOption.None;

            bool usingMenu = true;

            while (usingMenu)
            {
                //
                // set up display area
                //
                ConsoleUtil.HeaderText = "Edit Account";
                ConsoleUtil.DisplayReset();
                Console.CursorVisible = false;

                //
                // display the menu
                //
                ConsoleUtil.DisplayMessage("Please type the number of the account info you would like to edit:");
                ConsoleUtil.DisplayMessage("");
                Console.Write(
                    "\t" + "1. First Name" + Environment.NewLine +
                    "\t" + "2. Last Name" + Environment.NewLine +
                    "\t" + "3. Account ID" + Environment.NewLine +
                    "\t" + "4. Age" + Environment.NewLine +
                    "\t" + "5. Gender" + Environment.NewLine +
                    "\t" + "E. Exit" + Environment.NewLine);

                //
                // get and process the user's response
                // note: ReadKey argument set to "true" disables the echoing of the key press
                //
                ConsoleKeyInfo userResponse = Console.ReadKey(true);
                switch (userResponse.KeyChar)
                {
                case '1':
                    userMenuChoice = MenuOption.EditFirstName;
                    usingMenu      = false;
                    break;

                case '2':
                    userMenuChoice = MenuOption.EditLastName;
                    usingMenu      = false;
                    break;

                case '3':
                    userMenuChoice = MenuOption.EditAccountId;
                    usingMenu      = false;
                    break;

                case '4':
                    userMenuChoice = MenuOption.EditAge;
                    usingMenu      = false;
                    break;

                case '5':
                    userMenuChoice = MenuOption.EditGender;
                    usingMenu      = false;
                    break;

                case 'E':
                case 'e':
                    usingMenu = false;
                    break;

                default:
                    ConsoleUtil.DisplayMessage(
                        "It appears you have selected an incorrect choice." + Environment.NewLine +
                        "Press any key to continue or the ESC key to quit the application.");

                    userResponse = Console.ReadKey(true);
                    if (userResponse.Key == ConsoleKey.Escape)
                    {
                        usingMenu = false;
                    }
                    break;
                }
            }
            Console.CursorVisible = true;
            return(userMenuChoice);
        }