From 1e3a184417904373d99034d3c7af2e632b4efd91 Mon Sep 17 00:00:00 2001 From: zxc Date: Tue, 8 Sep 2026 17:15:37 +0300 Subject: [PATCH] laba2 --- works/sharp/lab-02/Program.cs | 104 ++++++++++++++++++++++++++++++++++ works/sharp/lab-02/Readme.md | 11 +--- 2 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 works/sharp/lab-02/Program.cs diff --git a/works/sharp/lab-02/Program.cs b/works/sharp/lab-02/Program.cs new file mode 100644 index 0000000..16a0da9 --- /dev/null +++ b/works/sharp/lab-02/Program.cs @@ -0,0 +1,104 @@ +using System; + +class Program +{ + static void Main() + { + /* Console.WriteLine("=== Leveling up a Pokemon ==="); + + // запрос базовой атаки + Console.Write("Enter the Pokemon's base attack value: "); + int Attack = int.Parse(Console.ReadLine()); + + // запрос количества полученных уровней + Console.Write("Enter the number of levels gained: "); + int level = int.Parse(Console.ReadLine()); + + // расчёт итоговой атаки + int finalAttack = Attack + (level * 5); + + Console.WriteLine($"Pokemon's final attack: {finalAttack}"); + + + // баланс тренера + int balans = 1500; + Console.Write($" trainer's current balance: {balans}"); + + //стоимость зелья + int potion = 200; + + //скок зельев хочешь то емае + Console.Write("How many potions did you buy?: "); + int quantity = int.Parse(Console.ReadLine()); + Console.WriteLine($"you bought: {quantity} potion"); + + //формула пока не один, но тоже сойдет + int by = potion * quantity; + int konec = balans - by; + Console.WriteLine($"You got a good one: {quantity} potion, and there remained {konec} money"); +*/ +/* + //запрос хэпэ + Console.Write("Enter HP: "); + int hp = int.Parse(Console.ReadLine()); + Console.WriteLine($"HP: {hp}"); + + if (hp <= 0) + { + Console.WriteLine("The Pokemon fainted! Return it to its Poke Ball."); + } + else if (hp >= 1 && hp <= 20) + { + Console.WriteLine("Critical condition! Use a potion immediately!"); + } + else if (hp >= 21 && hp <= 50) + { + Console.WriteLine("The Pokemon is injured; be careful."); + } + else + { + Console.WriteLine("The Pokemon is full of energy and ready for battle!"); + } + + + + } +} + +*/ + +using System; + +class Program +{ + static void Main() + { + Console.WriteLine("=== Combat Menu ==="); + Console.WriteLine("1 — Attack"); + Console.WriteLine("2 — Inventory"); + Console.WriteLine("3 — Switch Pokemon"); + Console.WriteLine("4 — Escape"); + Console.Write("select action (1-4):"); + + int choice = int.Parse(Console.ReadLine()); + + switch (choice) + { + case 1: + Console.WriteLine("The Pokemon lands a quick hit!"); + break; + case 2: + Console.WriteLine("You opened your bag and used a Healing Potion."); + break; + case 3: + Console.WriteLine("You recalled your Pokemon and sent out a new one!"); + break; + case 4: + Console.WriteLine("You successfully escaped from the battle!"); + break; + default: + Console.WriteLine("Unknown command! You missed your turn."); + break; + } + } +} \ No newline at end of file diff --git a/works/sharp/lab-02/Readme.md b/works/sharp/lab-02/Readme.md index 9756237..0496b87 100644 --- a/works/sharp/lab-02/Readme.md +++ b/works/sharp/lab-02/Readme.md @@ -1,15 +1,10 @@ # Лабораторная работа №2 -* **Студент:** [ФИО] -* **Вариант / Карточка:** [Например: #025 Pikachu] +* **Студент:** [Саженина Александра] +* **Вариант / Карточка:** [Преобразование типов данных (Convert, Parse) и математические операции в C#.] --- ## Ключевой код ```csharp -// Самая важная часть реализации (методы, структуры, логика) -public class Card -{ - public string Name { get; set; } - public int Hp { get; set; } -} +Исходный код расположен в файле Program.cs.