/// <summary>
        /// Prompts user for song name and artist and adds a new Song.
        /// </summary>
        static void AddSong()
        {
            bool done = false;

            do
            {
                string songName = CLI.Prompt("What's the name of the song? ");
                string artist   = CLI.Prompt("Who's the artist? ");

                _songs.Add(new Song {
                    Name = songName, Artist = artist
                });
                done = CLI.Prompt("Add another song? (y/n) ").ToLower() != "y";
            } while (!done);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displays the application menu and prompts the user for selection.
        /// </summary>
        /// <returns></returns>
        internal static int Prompt()
        {
            bool   valid        = false;
            int    parsedOption = 0;
            string option       = string.Empty;

            Display();
            do
            {
                option = CLI.Prompt($"Please select an option (1-{_options.Length}): ");
                bool canParse = int.TryParse(option, out parsedOption);
                valid = canParse && parsedOption > 0 && parsedOption <= 3;

                if (!valid)
                {
                    Console.WriteLine("'" + option + "' is not a valid option. Please provide a number 1-3");
                }
            }while (!valid);

            return(parsedOption);
        }