From 06be87a378ae8b473ac9999eb02ca46ebaea6935 Mon Sep 17 00:00:00 2001 From: polyphemus Date: Thu, 1 Oct 2026 11:11:18 +0300 Subject: [PATCH] lab-05 --- works/Csharp/lab-05/lab-05.sln | 16 +++++ works/Csharp/lab-05/lab-05/Program.cs | 76 ++++++++++++++++++++++++ works/Csharp/lab-05/lab-05/lab-05.csproj | 11 ++++ 3 files changed, 103 insertions(+) create mode 100644 works/Csharp/lab-05/lab-05.sln create mode 100644 works/Csharp/lab-05/lab-05/Program.cs create mode 100644 works/Csharp/lab-05/lab-05/lab-05.csproj diff --git a/works/Csharp/lab-05/lab-05.sln b/works/Csharp/lab-05/lab-05.sln new file mode 100644 index 0000000..52ca1fc --- /dev/null +++ b/works/Csharp/lab-05/lab-05.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-05", "lab-05\lab-05.csproj", "{11747B6F-8EF1-4EA0-8E81-AC9473C9C197}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {11747B6F-8EF1-4EA0-8E81-AC9473C9C197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11747B6F-8EF1-4EA0-8E81-AC9473C9C197}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11747B6F-8EF1-4EA0-8E81-AC9473C9C197}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11747B6F-8EF1-4EA0-8E81-AC9473C9C197}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/works/Csharp/lab-05/lab-05/Program.cs b/works/Csharp/lab-05/lab-05/Program.cs new file mode 100644 index 0000000..0fa7d12 --- /dev/null +++ b/works/Csharp/lab-05/lab-05/Program.cs @@ -0,0 +1,76 @@ +using System; +using System.Globalization; + +namespace Lab5 +{ + class Program + { + static void Main(string[] args) + { + CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("ru-RU"); + + // task 1 ref + Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ==="); + int pokemonHP = 20; + Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP."); + + HealPokemon(ref pokemonHP); + + Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.\n"); + + // task 2 out + Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ==="); + Console.WriteLine("Вы зашли в высокую траву..."); + + SearchBushes(out string foundPokemon, out int pokemonLevel); + + Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!\n"); + + + // task 3 in | params + Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ==="); + + // Первый вызов: 2 участника + RegisterTournament(1.5, "Булбазавр", "Чармандер"); + + Console.WriteLine("-----------------------------"); + + // Второй вызов: 4 участника + RegisterTournament(1.5, "Сквиртл", "Пикачу", "Псайдак", "Мяут"); + + Console.WriteLine("============================="); + } + + /// task 1 + static void HealPokemon(ref int hp) + { + hp += 80; + if (hp > 100) + { + hp = 100; + } + Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP."); + } + + /// task 2 + static void SearchBushes(out string foundPokemon, out int pokemonLevel) + { + Random random = new Random(); + foundPokemon = "Пикачу"; + pokemonLevel = random.Next(1, 16); + } + + /// task 3 + static void RegisterTournament(in double difficulty, params string[] participants) + { + + Console.WriteLine($"Коэффициент стадиона: {difficulty.ToString("0.0")}"); + Console.WriteLine("Список участников:"); + + foreach (string pokemon in participants) + { + Console.WriteLine($" * {pokemon}"); + } + } + } +} \ No newline at end of file diff --git a/works/Csharp/lab-05/lab-05/lab-05.csproj b/works/Csharp/lab-05/lab-05/lab-05.csproj new file mode 100644 index 0000000..d4ff536 --- /dev/null +++ b/works/Csharp/lab-05/lab-05/lab-05.csproj @@ -0,0 +1,11 @@ + + + + Exe + net10.0 + lab_05 + enable + enable + + +