Добавлены лабораторные работы

This commit is contained in:
228p
2026-09-29 14:17:11 +03:00
parent 6341b0aa57
commit c05629f619
106 changed files with 83985 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-03", "lab-03\lab-03.csproj", "{2EBADD5C-BB50-4CB1-96BC-88BEA04F9938}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2EBADD5C-BB50-4CB1-96BC-88BEA04F9938}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EBADD5C-BB50-4CB1-96BC-88BEA04F9938}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EBADD5C-BB50-4CB1-96BC-88BEA04F9938}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EBADD5C-BB50-4CB1-96BC-88BEA04F9938}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+101
View File
@@ -0,0 +1,101 @@
using System;
class Program
{
// static void Main(string[] args)
// {
// 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})");
// }
// задание 2
static void Main(string[] args)
{
string pokemon1Name = "Пикачу";
int pokemon1Hp = 50;
int pokemon1Attack = 12;
string pokemon2Name = "Булбазавр";
int pokemon2Hp = 55;
int pokemon2Attack = 10;
int roundNumber = 1;
int userChoice;
do
{
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
userChoice = int.Parse(Console.ReadLine());
if (userChoice != 1 && userChoice != 0)
{
Console.WriteLine("Некорректная команда! Попробуйте снова.");
}
} while (userChoice != 1 && userChoice != 0);
if (userChoice == 0)
{
Console.WriteLine("Вы отменили бой!");
return;
}
Console.WriteLine("Приготовьтесь!");
for (int i = 3; i >= 1; i--)
{
Console.WriteLine($"{i}...");
}
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
Console.WriteLine(
$"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
//zadanie3
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}");
roundNumber++;
}
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
if (pokemon1Hp > 0)
{
Console.WriteLine($"Победитель: {pokemon1Name}!");
}
else
{
Console.WriteLine($"Победитель: {pokemon2Name}!");
}
}
}
+11
View File
@@ -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>