Skip to content

Instantly share code, notes, and snippets.

@Waterhouze
Last active June 18, 2025 08:13
Show Gist options
  • Save Waterhouze/12ae6e21b6ba52ef5b3676508efc134a to your computer and use it in GitHub Desktop.
Save Waterhouze/12ae6e21b6ba52ef5b3676508efc134a to your computer and use it in GitHub Desktop.
ДЗ: Толковый словарь
using System;
using System.Text;
using System.Collections.Generic;
namespace hw.Lists._1_Dictionary
{
internal class Program
{
static void Main(string[] args)
{
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
const string CommandSearch = "1";
const string CommandExit = "2";
string userChoice;
bool isWork = true;
Dictionary<string, string> sepulka = new();
sepulka.Add("СЕПУЛЬКИ", "важный элемент цивилизации ардритов (см.) с планеты Энтеропия (см.). См. \"СЕПУЛЬКАРИИ\"");
sepulka.Add("СЕПУЛЬКАРИИ", "sустройства для сепуления; См. \"СЕПУЛЕНИЕ\"");
sepulka.Add("СЕПУЛЕНИЕ", "занятие ардритов (см.) с планеты Энтеропия (см.). См. \"СЕПУЛЬКИ\"");
while (isWork)
{
ShowMenu(CommandSearch, CommandExit);
userChoice = Console.ReadLine();
switch (userChoice)
{
case CommandSearch:
SearchDictionary(sepulka);
break;
case CommandExit:
isWork = false;
Console.WriteLine("Ойвсё, у меня обед");
break;
default:
Console.WriteLine("Ничо не понимаю, чё вы там мямлите?");
break;
}
}
}
private static void SearchDictionary(Dictionary<string, string> sepulka)
{
Console.Write("Тц, ну что вы хотите найти: ");
string userRequest = Console.ReadLine();
Console.WriteLine();
if (sepulka.ContainsKey(userRequest))
{
Console.WriteLine($"{userRequest} -- {sepulka[userRequest]}");
}
else
{
Console.WriteLine("Вот где такое услышали, туда и обращайтесь.");
}
}
static void ShowMenu(string commandSearch, string commandExit)
{
Console.WriteLine("\nВыберите ойдавысамизнаетечтоделать");
Console.WriteLine("Чтобы искать, введите: " + commandSearch);
Console.WriteLine("Чтобы exit эту program: " + commandExit);
Console.Write("Ну чего надо: ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment