private static void TestSimpleConsoleMenuHide() { SimpleConsoleMenu menu = new SimpleConsoleMenu("Choose an option:", "Option 1", "Option 2", "Option 3"); menu.Show(); menu.Hide(); Console.WriteLine($"You selected index {menu.SelectedIndex} which is '{menu.GetSelectedItemName()}'"); }
private static void TestSimpleConsoleMenuNoTitle() { SimpleConsoleMenu menu = new SimpleConsoleMenu(); menu.AddOption("Option 1"); menu.AddOption("Option 2"); menu.AddOption("Option 3"); menu.Show(); Console.WriteLine($"You selected index {menu.SelectedIndex} which is '{menu.GetSelectedItemName()}'"); }
private static void TestSimpleConsoleMenu3() { IEnumerable <string> options = new List <string>() { "Option 1", "Option 2", "Option 3" }; SimpleConsoleMenu menu = new SimpleConsoleMenu("Choose an option:", options); menu.Show(); Console.WriteLine($"You selected index {menu.SelectedIndex} which is '{menu.GetSelectedItemName()}'"); }
static void Main(string[] args) { Console.Title = "Yonatan's Synonyms Practice Tool"; Console.CursorVisible = false; int wrongAnswerCount = 0; int questionNumber = 1; foreach (KeywordTest keywordTest in KeywordTest.GetKeywordTests(keywords)) { Console.WriteLine($"[Question {questionNumber++} of {keywords.Count}]\n"); Console.Write("Which of the following is not a synonym of "); WriteInColor(keywordTest.Word, ConsoleColor.Yellow, ConsoleColor.Black); Console.WriteLine("?"); IList <string> keywordTestSynonyms = keywordTest.GetSynonyms(); SimpleConsoleMenu synonymsMenu = new SimpleConsoleMenu("", keywordTestSynonyms); Console.WriteLine(); synonymsMenu.Show(); Console.WriteLine(); if (synonymsMenu.SelectedIndex == keywordTest.IndexOfBadSynonym) { WriteInColor("Correct!\n", ConsoleColor.Green, ConsoleColor.Black); } else { WriteInColor("Wrong.", ConsoleColor.Red, ConsoleColor.White); Console.WriteLine($" The correct answer was '{keywordTestSynonyms[keywordTest.IndexOfBadSynonym]}'."); wrongAnswerCount++; } Keyword keywordOfWrongSynonym = keywords.GetKeywordOfSynonym(keywordTestSynonyms[keywordTest.IndexOfBadSynonym]); Console.WriteLine($"'{keywordOfWrongSynonym.GetSynonyms()[keywordTest.IndexOfBadSynonym]}' means '{keywordOfWrongSynonym.Word}'.\n"); Console.WriteLine("Hit ENTER to continue:"); Console.ReadLine(); Console.Clear(); } Console.WriteLine($"You answered correctly on {keywords.Count - wrongAnswerCount} out of {keywords.Count} questions. " + $"({(keywords.Count - wrongAnswerCount) * 100 / keywords.Count}%)"); Console.ReadKey(); }