예제 #1
0
        /// OPTION 1 - Prompts user for details of new device.
        static void AddDevice()
        {
            bool done = false;

            do
            {
                string location   = Welcome.Prompt("Where is the device located? ");
                string deviceName = Welcome.Prompt("What type of device are you adding? ");
                string deviceType = Welcome.Prompt("What type of device is the deviceType?  ");
                string brand      = Welcome.Prompt("Who makes the brand of the device?  ");
                string quantity   = Welcome.Prompt("How many of these devices are you adding?  ");

                _device.Add(new ListOfDevices {
                    Location = location, DeviceName = deviceName, DeviceType = deviceType, Brand = brand, Quantity = quantity
                });
                done = Welcome.Prompt("Add another device? (y/n) ").ToLower() != "y";
            } while (!done);
        }
예제 #2
0
        /// Displays the application menu and prompts the user for selection.
        internal static int Prompt()
        {
            bool   valid        = false;
            int    parsedOption = 0;
            string option       = string.Empty;

            Display();
            do
            {
                option = Welcome.Prompt($"Please select an option (1-{_options.Length}): ");
                bool canParse = int.TryParse(option, out parsedOption);
                valid = canParse && parsedOption > 0 && parsedOption <= 4;
                if (!valid)
                {
                    Console.WriteLine("'" + option + "' is not a valid option. Please provide a number 1-6");
                }
            }while (!valid);
            return(parsedOption);
        }