From 3602309ee1a6759988b3e10568bfaba3f03b0093 Mon Sep 17 00:00:00 2001 From: anazaz Date: Thu, 24 Sep 2026 08:24:32 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?works/c#/lab2=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/c#/lab2/Program.cs | 105 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 works/c#/lab2/Program.cs diff --git a/works/c#/lab2/Program.cs b/works/c#/lab2/Program.cs new file mode 100644 index 0000000..df3e46d --- /dev/null +++ b/works/c#/lab2/Program.cs @@ -0,0 +1,105 @@ +using System; + +namespace LaboratoryWork2 +{ + internal class Program + { + static void Main(string[] args) + { + + Console.WriteLine("=== Прокачка покемона ==="); + + Console.Write("Введите базовую атаку покемона: "); + int baseAttack = int.Parse(Console.ReadLine()); + + Console.Write("Введите количество полученных уровней: "); + int levelsGained = int.Parse(Console.ReadLine()); + + int totalAttack = baseAttack + (levelsGained * 5); + Console.WriteLine($"Итоговая атака покемона: {totalAttack}"); + + Console.WriteLine(); + + Console.WriteLine("=== Магазин предметного инвентаря ==="); + int initialBalance = 1500; + int potionCost = 200; + + Console.WriteLine($"Текущий баланс тренера: {initialBalance} монет"); + Console.WriteLine($"Стоимость одного Зелья Лечения (Potion): {potionCost} монет"); + + Console.Write("Введите количество приобретаемых зелий: "); + int potionsToBuy = int.Parse(Console.ReadLine()); + + int totalCost = potionsToBuy * potionCost; + int remainingBalance = initialBalance - totalCost; + + if (remainingBalance >= 0) + { + Console.WriteLine($"Покупка успешна! Вы приобрели зелий: {potionsToBuy} шт."); + Console.WriteLine($"Общая стоимость: {totalCost} монет. Остаток на балансе: {remainingBalance} монет."); + } + else + { + Console.WriteLine($"Недостаточно средств! Стоимость покупки ({totalCost} монет) превышает ваш баланс."); + } + + Console.WriteLine(); // Пустая строка для разделения + + Console.WriteLine("=== Анализ состояния покемона ==="); + Console.Write("Введите текущее количество HP покемона: "); + int currentHp = int.Parse(Console.ReadLine()); + + if (currentHp <= 0) + { + Console.WriteLine("Покемон потерял сознание! Верните его в покебол."); + } + else if (currentHp >= 1 && currentHp <= 20) + { + Console.WriteLine("Критическое состояние! Срочно используйте зелье!"); + } + else if (currentHp >= 21 && currentHp <= 50) + { + Console.WriteLine("Покемон ранен, будьте осторожны."); + } + else + { + Console.WriteLine("Покемон полон сил и готов к бою!"); + } + + Console.WriteLine(); + + Console.WriteLine("=== Ход в бою ==="); + Console.WriteLine("Выберите действие:"); + Console.WriteLine("1 — Атака"); + Console.WriteLine("2 — Инвентарь"); + Console.WriteLine("3 — Сменить покемона"); + Console.WriteLine("4 — Побег"); + + Console.Write("Введите номер действия: "); + int actionChoice = int.Parse(Console.ReadLine()); + + switch (actionChoice) + { + case 1: + Console.WriteLine("Покемон наносит быстрый удар!"); + break; + case 2: + Console.WriteLine("Вы открыли сумку и применили Зелье Лечения."); + break; + case 3: + Console.WriteLine("Вы отозвали покемона и выпустили нового!"); + break; + case 4: + Console.WriteLine("Вы успешно сбежали из боя!"); + break; + default: + Console.WriteLine("Неизвестная команда! Вы пропустили ход."); + break; + } + + Console.WriteLine(); + Console.WriteLine("Нажмите любую клавишу для завершения..."); + Console.ReadKey(); + } + } +} \ No newline at end of file