generated from admin/template
edit lab-03
This commit is contained in:
@@ -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 ++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+19
-22
@@ -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 ++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>lab_03</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Reference in New Issue
Block a user