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

This commit is contained in:
2026-10-09 14:43:11 +03:00
parent 1b22247753
commit d78082aa54
9 changed files with 236 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", "{6871B9F6-A864-4C10-B709-26BB6F5D8ED0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6871B9F6-A864-4C10-B709-26BB6F5D8ED0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6871B9F6-A864-4C10-B709-26BB6F5D8ED0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6871B9F6-A864-4C10-B709-26BB6F5D8ED0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6871B9F6-A864-4C10-B709-26BB6F5D8ED0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -0,0 +1,82 @@
/*
string pokemon1Name = "Пикачу";
int pokemon1Hp = 50;
int pokemon1Attack = 12;
string pokemon2Name = "Булбазавр";
int pokemon2Hp = 55;
int pokemon2Attack = 10;
int roundNumber = 1;
Console.WriteLine("Приготовьтесь!");
for (int i = 3 ; i >= roundNumber ; i--)
{
Console.WriteLine(i + "...");
Thread.Sleep(1000);
}
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
*/
/*
int choice;
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
do
{
choice = int.Parse(Console.ReadLine());
if (choice == 1)
{
Console.WriteLine("Вы начали бой!");
}
else if (choice == 0)
{
Console.WriteLine("Вы отменили бой!");
}
else
{
Console.WriteLine("Некорректная команда! Попробуйте снова.");
}
} while (choice != 1 && choice != 0);
*/
string pokemon1Name = "Пикачу";
int pokemon1Hp = 50;
int pokemon1Attack = 12;
string pokemon2Name = "Булбазавр";
int pokemon2Hp = 55;
int pokemon2Attack = 10;
int roundNumber = 1;
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}!");
}
@@ -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>
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-04", "lab-04\lab-04.csproj", "{66B65B18-5E4D-4C31-A341-120C886EF055}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66B65B18-5E4D-4C31-A341-120C886EF055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66B65B18-5E4D-4C31-A341-120C886EF055}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66B65B18-5E4D-4C31-A341-120C886EF055}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66B65B18-5E4D-4C31-A341-120C886EF055}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -0,0 +1,32 @@
/*
string[] activeTeam = new string[3];
Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ===");
for (int i = 0; i < activeTeam.Length; i++)
{
Console.Write($"Введите имя покемона №{i + 1}: ");
activeTeam[i] = Console.ReadLine();
}
Console.WriteLine("--- Ваша команда на этот бой ---");
Console.WriteLine($"1. {activeTeam[0]}");
Console.WriteLine($"2. {activeTeam[1]}");
Console.WriteLine($"3. {activeTeam[2]}");
*/
List<string> backpack = new List<string>();
backpack.Add("Зелье HP");
backpack.Add("Покебол");
backpack.Add("Антидот");
Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ===");
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре:{backpack.Count}");
backpack.Remove("Покебол");
Console.WriteLine($"Вы использовали один Покебол для поимки дикого покемона!");
Console.WriteLine($"Обновленный инвентарь. Осталось предметов:{backpack.Count}");
Console.WriteLine("--- Содержимое вашей сумки ---");
foreach (var item in backpack)
{
Console.WriteLine($"[Предмет] -> {item}");
}
Console.WriteLine("=============================");
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>lab_04</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-05", "lab-05\lab-05.csproj", "{4A0876E9-98DB-456A-8F80-868CC87C16A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4A0876E9-98DB-456A-8F80-868CC87C16A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A0876E9-98DB-456A-8F80-868CC87C16A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A0876E9-98DB-456A-8F80-868CC87C16A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A0876E9-98DB-456A-8F80-868CC87C16A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+41
View File
@@ -0,0 +1,41 @@
int pokemonHP = 20;
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
HealPokemon(ref pokemonHP);
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
static void HealPokemon(ref int hp)
{
hp += 80;
Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
}
Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в высокую траву...");
SearchBushes(out string foundPokemon, out int pokemonLevel);
Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!");
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
Random random = new Random();
foundPokemon = "Пикачу";
pokemonLevel = random.Next(1, 16);
}
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
RegisterTournament(1.5, "Бульбазавр", "Чармандер");
RegisterTournament(1.5, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
static void RegisterTournament(in double difficulty, params string[] participants)
{
Console.WriteLine("-----------------------------");
Console.WriteLine($"Коэффициент стадиона: {difficulty} ");
Console.WriteLine("Список участников: ");
foreach (string pokemon in participants)
{
Console.WriteLine($"* {pokemon} ");
}
}
Console.WriteLine("=============================");
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>lab_05</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>