diff --git a/works/lab-03/src/lesson3.cs b/works/lab-03/Program.cs similarity index 74% rename from works/lab-03/src/lesson3.cs rename to works/lab-03/Program.cs index 62d8078..0124936 100644 --- a/works/lab-03/src/lesson3.cs +++ b/works/lab-03/Program.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; - -namespace lesson3 -{ - internal class Program +internal class Program { static void Main(string[] args) { @@ -16,26 +9,23 @@ namespace lesson3 int pokemon2Hp = 55; int pokemon2Attack = 10; int roundNumber = 1; - + int actionChoise; //задание 2 do { Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); - int check = int.Parse(Console.ReadLine()); - if (check == 0) - { - Console.WriteLine("\nВы отменили бой!"); - break; - } - else if (check == 1) - { - Console.WriteLine("\nВы приняли бой!"); - break; - } - else - Console.WriteLine("\nНекорректная команда! Попробуйте снова."); - }while (true); - + actionChoise = int.Parse(Console.ReadLine()); + if (actionChoise != 1 && actionChoise != 0) + Console.WriteLine("Некорректная команда! Попробуйте снова."); + }while (actionChoise != 1 && actionChoise != 0); + if (actionChoise == 0) + { + Console.WriteLine("\nВы отменили бой!"); + } + else if (actionChoise == 1) + { + Console.WriteLine("\nВы приняли бой!"); + } //задание 1 Console.WriteLine("Приготовьтесь!"); for (int i = 3; i > 0; i--) @@ -45,14 +35,12 @@ namespace lesson3 Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); - - //задание 3 while (pokemon1Hp > 0 && pokemon2Hp > 0) { - Console.WriteLine($"--- Раунд {roundNumber} ---"); + Console.WriteLine($"\n--- Раунд {roundNumber} ---"); Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); pokemon2Hp -= pokemon1Attack; if (pokemon2Hp <= 0) @@ -74,12 +62,9 @@ namespace lesson3 break; } Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}"); - Console.WriteLine(); roundNumber ++; } } - } - -} \ No newline at end of file + } \ No newline at end of file diff --git a/works/lab-03/Readme.md b/works/lab-03/Readme.md index 47a1043..f4232f4 100644 --- a/works/lab-03/Readme.md +++ b/works/lab-03/Readme.md @@ -8,7 +8,7 @@ ## Ключевой код ```csharp // Самая важная часть реализации (методы, структуры, логика) - internal class Program + internal class Program { static void Main(string[] args) { @@ -19,25 +19,23 @@ int pokemon2Hp = 55; int pokemon2Attack = 10; int roundNumber = 1; - + int actionChoise; //задание 2 do { Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); - int check = int.Parse(Console.ReadLine()); - if (check == 0) - { - Console.WriteLine("\nВы отменили бой!"); - break; - } - else if (check == 1) - { - Console.WriteLine("\nВы приняли бой!"); - break; - } - else - Console.WriteLine("\nНекорректная команда! Попробуйте снова."); - }while (true); + actionChoise = int.Parse(Console.ReadLine()); + if (actionChoise != 1 && actionChoise != 0) + Console.WriteLine("Некорректная команда! Попробуйте снова."); + }while (actionChoise != 1 && actionChoise != 0); + if (actionChoise == 0) + { + Console.WriteLine("\nВы отменили бой!"); + } + else if (actionChoise == 1) + { + Console.WriteLine("\nВы приняли бой!"); + } //задание 1 Console.WriteLine("Приготовьтесь!"); for (int i = 3; i > 0; i--) @@ -46,15 +44,15 @@ } Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); + - - - + + //задание 3 while (pokemon1Hp > 0 && pokemon2Hp > 0) { - Console.WriteLine($"--- Раунд {roundNumber} ---"); + Console.WriteLine($"\n--- Раунд {roundNumber} ---"); Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); pokemon2Hp -= pokemon1Attack; if (pokemon2Hp <= 0) @@ -76,10 +74,9 @@ break; } Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}"); - Console.WriteLine(); roundNumber ++; } - + } } \ No newline at end of file diff --git a/works/lab-03/lab-03.csproj b/works/lab-03/lab-03.csproj new file mode 100644 index 0000000..785b153 --- /dev/null +++ b/works/lab-03/lab-03.csproj @@ -0,0 +1,11 @@ + + + + Exe + net10.0 + lab_03 + enable + enable + + + diff --git a/works/lab-03/lab-03.sln b/works/lab-03/lab-03.sln new file mode 100644 index 0000000..10db557 --- /dev/null +++ b/works/lab-03/lab-03.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-03", "lab-03.csproj", "{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/works/lab-03/screenshots/Вывод программы.png b/works/lab-03/screenshots/Вывод программы.png new file mode 100644 index 0000000..8e099b4 Binary files /dev/null and b/works/lab-03/screenshots/Вывод программы.png differ