generated from admin/template
Лаб5 шарп
This commit is contained in:
@@ -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>
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stage5", "stage5\stage5.csproj", "{6EF2759F-30FC-480F-A76F-8BB3618AE6AD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6EF2759F-30FC-480F-A76F-8BB3618AE6AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6EF2759F-30FC-480F-A76F-8BB3618AE6AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6EF2759F-30FC-480F-A76F-8BB3618AE6AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6EF2759F-30FC-480F-A76F-8BB3618AE6AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,78 @@
|
||||
Console.WriteLine("=== БОЕВОЙ КАЛЬКУЛЯТОР ===");
|
||||
int enemyDamage = 25;
|
||||
int currentAttackType = 1;
|
||||
Console.Write($"Базовый урон противника: {enemyDamage}");
|
||||
Console.WriteLine($"Тип атаки (1 - Боевой, 2 - Стальной, 3 - Обычный): {currentAttackType}");
|
||||
int finalDamage = CalculateIncomingDamage(in enemyDamage, in currentAttackType);
|
||||
Console.WriteLine("[Калькулятор] Расчёт: Боевой тип! Урон удваивается.");
|
||||
Console.WriteLine($"Итоговый нанесенный урон {finalDamage}");
|
||||
Console.WriteLine("=== СИСТЕМА ИНВЕНТАРЯ ===");
|
||||
int pokemonHP = 25;
|
||||
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
|
||||
List<string> bag = new List<string>
|
||||
{
|
||||
"Зелье HP", "Зелье OP", "Покебол"
|
||||
};
|
||||
int remainingItems;
|
||||
UseItem(ref pokemonHP, bag, out remainingItems);
|
||||
Console.WriteLine($"Осталось предметов в сумке: {remainingItems}");
|
||||
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
|
||||
|
||||
LogRoundEvents(
|
||||
"Пикачу использует Быстрая Атака!",
|
||||
"Выпал орёл! Нанесен критический урон.",
|
||||
"Враг Булбазавр потерял 30 HP."
|
||||
);
|
||||
static int CalculateIncomingDamage(in int baseDamage, in int attackType)
|
||||
{
|
||||
//baseDamage = 20; in передает аргумент по ссылке,
|
||||
//но запрещает его изменение внутри метода (переменная доступна только для чтения)
|
||||
int finalDamage = baseDamage;
|
||||
switch (attackType)
|
||||
{
|
||||
case 1:
|
||||
finalDamage = baseDamage * 2;
|
||||
break;
|
||||
case 2:
|
||||
finalDamage = baseDamage - 20;
|
||||
if (finalDamage < 0)
|
||||
{
|
||||
finalDamage = 0;
|
||||
}
|
||||
break;
|
||||
case 3 :
|
||||
finalDamage = baseDamage;
|
||||
break;
|
||||
}
|
||||
return finalDamage;
|
||||
}
|
||||
|
||||
static void UseItem(ref int pokemonHP, List<string> bag, out int itemsLeft)
|
||||
{
|
||||
if (bag.Contains("Зелье HP"))
|
||||
{
|
||||
pokemonHP += 30;
|
||||
bag.Remove("Зелье HP");
|
||||
Console.WriteLine("[Предмет] Использовано: Зелье HP. Здоровье восстановлено на +30!");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Console.WriteLine("У Вас нет зелья HP");
|
||||
}
|
||||
}
|
||||
|
||||
itemsLeft = bag.Count;
|
||||
}
|
||||
|
||||
static void LogRoundEvents(params string[] events)
|
||||
{
|
||||
Console.WriteLine("--- ЛОГ ТЕКУЩЕГО РАУНДА ---");
|
||||
|
||||
foreach (string currentEvent in events)
|
||||
{
|
||||
Console.WriteLine($"[БОЙ]: {currentEvent}");
|
||||
}
|
||||
|
||||
Console.WriteLine("-------------------------");
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user