diff --git a/works/lab-02/MyDll.dll b/works/lab-02/MyDll.dll
new file mode 100644
index 0000000..bfc7e44
Binary files /dev/null and b/works/lab-02/MyDll.dll differ
diff --git a/works/lab-02/Program.cs b/works/lab-02/Program.cs
new file mode 100644
index 0000000..45daf34
--- /dev/null
+++ b/works/lab-02/Program.cs
@@ -0,0 +1,240 @@
+using System;
+using HelpMethods;
+
+namespace Test
+{
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ short initialBalance = 1500;
+
+ PokemonLeveling();
+ BuyPotion(initialBalance);
+ ShowCondition();
+ TUI();
+ }
+
+ ///
+ /// Метод для задания №1.
+ ///
+ static void PokemonLeveling()
+ {
+ const sbyte MARGIN_1 = -16;
+
+ short pokemonAttack = SetPokemonAttack();
+ byte ernedLevels = LevelsRequest();
+
+ string message =
+$@"=== Pokemon leveling ===
+{"Initial attack:",MARGIN_1}{pokemonAttack}
+{"Earned levels:",MARGIN_1}{ernedLevels}
+
+Final attack: {pokemonAttack + ernedLevels * 5}
+------------------------
+";
+
+ Console.WriteLine(message);
+ SystemHelp.Waiting(true);
+
+
+ static short SetPokemonAttack()
+ {
+ const short
+ MAX_ATTACK = 250
+ , MIN_ATTACK = 1;
+
+ string ERROR = $"The attack power must be between {MIN_ATTACK} and {MAX_ATTACK}.";
+
+ while (true)
+ {
+ try
+ {
+ Console.Write("Set the attack strength.\nAttack strength: ");
+ short attack = short.Parse(Console.ReadLine());
+
+ if (attack < MIN_ATTACK || attack > MAX_ATTACK)
+ throw new Exception(ERROR);
+
+ Console.Clear();
+
+ return attack;
+ }
+ catch (Exception e) { SystemHelp.PrintError(e); }
+ }
+ }
+ static byte LevelsRequest()
+ {
+ const short MAX_COUNT = 5;
+
+ string ERROR = $"The number of levels cannot exceed {MAX_COUNT}.";
+
+ while (true)
+ {
+ try
+ {
+ Console.Write("How many levels have been earned?\nCount: ");
+ byte lvl = byte.Parse(Console.ReadLine());
+
+ if (lvl > MAX_COUNT)
+ throw new Exception(ERROR);
+
+ Console.Clear();
+
+ return lvl;
+ }
+ catch (Exception e) { SystemHelp.PrintError(e); }
+ }
+ }
+ }
+
+ ///
+ /// Метод для задания №2.
+ ///
+ ///
+ static void BuyPotion(short balance)
+ {
+ const byte COST_POTION = 200;
+
+ byte countPotions = GetCountPotions(balance, COST_POTION);
+ PrintCheque(balance, countPotions, COST_POTION);
+ SystemHelp.Waiting(true);
+
+
+ static byte GetCountPotions(short balance, byte costPotion)
+ {
+ const string ERROR = "The purchase amount cannot exceed your balance.";
+ string message = $"Your balance: {balance}\nHow many potions do you want to buy?\nCount: ";
+
+ while (true)
+ {
+ try
+ {
+ Console.Write(message);
+ byte count = byte.Parse(Console.ReadLine());
+
+ if (balance - costPotion * count < 0)
+ throw new Exception(ERROR);
+
+ return count;
+ }
+ catch (Exception e) { SystemHelp.PrintError(e); }
+ }
+ }
+ static short PrintCheque(short balance, byte countPotions, byte costPotion)
+ {
+ const sbyte MARGIN_1 = -10;
+
+ string cheque =
+$@"
+====== Cheque ======
+{"Balance:",MARGIN_1}{balance}
+{"Purchase:",MARGIN_1}{costPotion} X{countPotions}
+Amount to be paid:{costPotion * countPotions}
+
+Remains:{balance - costPotion * countPotions}
+---------------------
+
+";
+
+ Console.Write(cheque);
+
+ return (short)(balance - costPotion * countPotions);
+ }
+ }
+
+ ///
+ /// Метод для задания №3.
+ ///
+ static void ShowCondition()
+ {
+ const string
+ MESSAGE_1 = "Pokemon lost consciousness!"
+ , MESSAGE_2 = "The Pokemon is in critical condition!"
+ , MESSAGE_3 = "The Pokemon is wounded!"
+ , MESSAGE_4 = "The Pokemon has full HP!";
+
+ short pokemonHp = GetPokemonHp();
+
+ if (pokemonHp == 0)
+ Console.WriteLine(MESSAGE_1);
+ else if (pokemonHp < 21)
+ Console.WriteLine(MESSAGE_2);
+ else if (pokemonHp < 51)
+ Console.WriteLine(MESSAGE_3);
+ else
+ Console.WriteLine(MESSAGE_4);
+
+ StringHelp.Br();
+
+ SystemHelp.Waiting(true);
+
+ static short GetPokemonHp()
+ {
+ const short
+ MIN_HP = 0
+ , MAX_HP = 5000;
+
+ string ERROR = $"Hp should be between {MIN_HP} and {MAX_HP}";
+
+ while (true)
+ {
+ try
+ {
+ Console.Write("Enter the number of HP.\nHP: ");
+ short hp = short.Parse(Console.ReadLine());
+
+ if (hp MAX_HP)
+ throw new Exception(ERROR);
+
+ return hp;
+ }
+ catch (Exception e) { SystemHelp.PrintError(e); }
+ }
+ }
+ }
+
+ ///
+ /// Метод для задания №4.
+ ///
+ static void TUI()
+ {
+ const string hotBar =
+@"
+====== Actions ======
+Attack [1]
+Backpack [2]
+Change the Pokemon [3]
+Escape [4]
+-----------------------
+
+";
+
+ Console.Write(hotBar);
+
+ ModuleAction(Console.ReadLine() ?? String.Empty);
+
+ StringHelp.Br();
+
+ static void ModuleAction(string action)
+ {
+ const string
+ ACTION_1 = "The Pokemon delivers a quick strike!"
+ , ACTION_2 = "You open the backpack!"
+ , ACTION_3 = "You choose other Pokemon!"
+ , ACTION_4 = "You escape!"
+ , DEFAULT_ACTION = "You didn’t do anything!";
+
+
+ switch (action)
+ {
+ case "1": Console.WriteLine(ACTION_1); break;
+ case "2": Console.WriteLine(ACTION_2); break;
+ case "3": Console.WriteLine(ACTION_3); break;
+ case "4": Console.WriteLine(ACTION_4); break;
+ default: Console.WriteLine(DEFAULT_ACTION); break;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/works/lab-02/Test.csproj b/works/lab-02/Test.csproj
new file mode 100644
index 0000000..81f2966
--- /dev/null
+++ b/works/lab-02/Test.csproj
@@ -0,0 +1,58 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {0580ACC5-9C57-48B6-A97B-75103119F024}
+ Exe
+ Test
+ Test
+ v4.8
+ latest
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ .\MyDll.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file