public static void Show() { var numbers = Array.ConvertAll(FileUtilities.Read("cisla.txt"), int.Parse); var tree = new Tree(); foreach (var number in numbers) { tree.Insert(number); } var operations = new Dictionary <int, IOperation> { { 1, new FindOperation(tree) }, { 2, new InsertOperation(tree) }, { 3, new RemoveOperation(tree) } }; while (true) { ConsoleUtilities.DisplayMenu(options: new[] { "1. Najit prvek", "2. Pridat prvek", "3. Odebrat prvek" }); ConsoleUtilities.Prompt("\nZvolte moznost: "); var operation = ConsoleUtilities.GetUserInput(); if (!operations.ContainsKey(operation)) { ConsoleUtilities.Prompt("\nNespravna volba. Ukonceni aplikace...\n"); break; } operations.Where(o => o.Key == operation).First().Value.Perform(); ConsoleUtilities.Prompt($"\n{new string('-', 30)}\n"); } }
public static void Show() { ConsoleUtilities.Prompt("Zadejte velikost zasobniku: "); var stack = new Stack(size: ConsoleUtilities.GetUserInput()); var operations = new Dictionary <int, IOperation> { { 1, new PushOperation(stack) }, { 2, new PopOperation(stack) } }; while (true) { ConsoleUtilities.DisplayMenu(options: new[] { "\n1. Pridat", "2. Odebrat", "3. Odejit" }); ConsoleUtilities.Prompt("\nZvolte moznost: "); var operation = ConsoleUtilities.GetUserInput(); if (!operations.ContainsKey(operation)) { ConsoleUtilities.Prompt("\nUkonceni aplikace...\n"); break; } operations.Where(o => o.Key == operation).First().Value.Perform(); ConsoleUtilities.Prompt($"\n{new string('-', 30)}\n"); } }