Лаб5 шарп

This commit is contained in:
328p
2026-09-30 12:04:05 +03:00
parent 399c28eb26
commit 27548ae05a
6 changed files with 172 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}") = "lesson5", "lesson5\lesson5.csproj", "{3C00FB33-B98C-4DD0-826F-F76A2854EE8E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C00FB33-B98C-4DD0-826F-F76A2854EE8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C00FB33-B98C-4DD0-826F-F76A2854EE8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C00FB33-B98C-4DD0-826F-F76A2854EE8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C00FB33-B98C-4DD0-826F-F76A2854EE8E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -0,0 +1,42 @@
int pokemonHp = 20;
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
Console.WriteLine($"Здоровье до лечения: {pokemonHp} HP");
HealPokemon(ref pokemonHp);
Console.WriteLine($"Здоровье после лечения: {pokemonHp} HP");
Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в высокую траву...");
string foundPokemon;
int pokemonLevel;
SearchBushes(out foundPokemon, out pokemonLevel);
Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!");
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
double arenaDifficulty = 1.5;
RegisterTournament(arenaDifficulty, "Булбазавр", "Чармандер");
Console.WriteLine("-----------------------------");
RegisterTournament(arenaDifficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
Console.WriteLine("-----------------------------");
static void HealPokemon(ref int hp)
{
hp += 80;
Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
}
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
foundPokemon = "Пикачу";
Random random = new Random();
pokemonLevel = random.Next(1,15);
}
static void RegisterTournament(in double difficulty, params string[] participants)
{
foreach (var pokemon in participants)
{
Console.WriteLine($" * {pokemon}");
}
}
@@ -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>