generated from admin/template
laba 3
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D959845F-02D5-4C96-9BED-432306BA3585}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D959845F-02D5-4C96-9BED-432306BA3585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D959845F-02D5-4C96-9BED-432306BA3585}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D959845F-02D5-4C96-9BED-432306BA3585}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D959845F-02D5-4C96-9BED-432306BA3585}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp3
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// ЗАДАНИЕ 1
|
||||
|
||||
Console.WriteLine("Приготовьтесь!");
|
||||
|
||||
for (int i = 3; i >= 1; i--)
|
||||
{
|
||||
Console.WriteLine($"{i}...");
|
||||
}
|
||||
|
||||
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
|
||||
|
||||
string pokemon1Name = "Пикачу";
|
||||
int pokemon1Hp = 50;
|
||||
int pokemon1Attack = 12;
|
||||
|
||||
string pokemon2Name = "Булбазавр";
|
||||
int pokemon2Hp = 55;
|
||||
int pokemon2Attack = 10;
|
||||
|
||||
int roundNumber = 1;
|
||||
|
||||
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS " +
|
||||
$"{pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||
Console.WriteLine();
|
||||
|
||||
// ЗАДАНИЕ 2
|
||||
|
||||
int command;
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||
command = int.Parse(Console.ReadLine());
|
||||
|
||||
if (command != 1 && command != 0)
|
||||
{
|
||||
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||
}
|
||||
} while (command != 1 && command != 0);
|
||||
|
||||
if (command == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
return;
|
||||
}
|
||||
|
||||
// ЗАДАНИЕ 3
|
||||
|
||||
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
|
||||
// Ход Пикачу
|
||||
pokemon2Hp -= pokemon1Attack;
|
||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||
|
||||
if (pokemon2Hp <= 0)
|
||||
{
|
||||
pokemon2Hp = 0;
|
||||
Console.WriteLine($"{pokemon2Name} потерял сознание!");
|
||||
break;
|
||||
}
|
||||
pokemon1Hp -= pokemon2Attack;
|
||||
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||
|
||||
if (pokemon1Hp <= 0)
|
||||
{
|
||||
pokemon1Hp = 0;
|
||||
Console.WriteLine($"{pokemon1Name} потерял сознание!");
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | " +
|
||||
$"{pokemon2Name} HP: {pokemon2Hp}");
|
||||
Console.WriteLine();
|
||||
|
||||
roundNumber++;
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||
|
||||
if (pokemon2Hp <= 0 && pokemon1Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon1Name}!");
|
||||
}
|
||||
else if (pokemon1Hp <= 0 && pokemon2Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon2Name}!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Ничья!");
|
||||
}
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user