Compare commits

..
8 Commits
Author SHA1 Message Date
328p f38ab97b5f lab601 2026-10-29 15:49:57 +03:00
328p f3dc03ca4d lab6 2026-10-29 15:42:31 +03:00
328p 180febf6b9 lab5 2026-10-29 15:39:25 +03:00
328p d22851046c 4 2026-09-23 15:58:23 +03:00
328p 1f8605dd84 3 2026-09-23 15:37:36 +03:00
328p b8fbd25206 2 2026-09-23 11:34:53 +03:00
328p 5addfcbfb0 Merge branch 'main' of http://31.128.39.10:3000/petershoes/csharp 2026-09-23 11:23:41 +03:00
328p 384b7f4b5e 1 2026-09-23 11:23:33 +03:00
22 changed files with 604 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2", "2\2.csproj", "{D6AB85A1-8C23-4CB5-9086-7F3515A4E0CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6AB85A1-8C23-4CB5-9086-7F3515A4E0CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6AB85A1-8C23-4CB5-9086-7F3515A4E0CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6AB85A1-8C23-4CB5-9086-7F3515A4E0CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6AB85A1-8C23-4CB5-9086-7F3515A4E0CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>_2</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+65
View File
@@ -0,0 +1,65 @@
using System;
namespace PokemonBattle
{
class Program
{
static void Main(string[] args)
{
// задание 2.1
Console.WriteLine("Введите текущее количество HP покемона: ");
int pokemonHp = int.Parse(Console.ReadLine());
if (pokemonHp <= 0)
{
Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
}
else if (pokemonHp >= 1 && pokemonHp <= 20)
{
Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
}
else if (pokemonHp >= 21 && pokemonHp <= 50)
{
Console.WriteLine("Покемон ранен, будьте осторожны.");
}
else
{
Console.WriteLine("Покемон полон сил и готов к бою!");
}
Console.WriteLine();
// задание 2.2
Console.WriteLine("Выберете действие тренера:");
Console.WriteLine("1 — Атака");
Console.WriteLine("2 — Инвентарь");
Console.WriteLine("3 — Сменить покемона");
Console.WriteLine("4 — Побег");
Console.Write("Введите номер действия: ");
int trainerChoice = int.Parse(Console.ReadLine());
switch (trainerChoice)
{
case 1:
Console.WriteLine("Покемон наносит быстрый удар!");
break;
case 2:
Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
break;
case 3:
Console.WriteLine("Вы отозвали покемона и выпустили нового!");
break;
case 4:
Console.WriteLine("Вы успешно сбежали из боя!");
break;
default:
Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
break;
}
Console.ReadLine();
}
}
}
+1 -1
View File
@@ -18,6 +18,6 @@ class Program
Console.WriteLine($"Введите кол-во приобритаемых зелий"); Console.WriteLine($"Введите кол-во приобритаемых зелий");
int purchase = healPotion * int.Parse(Console.ReadLine()); int purchase = healPotion * int.Parse(Console.ReadLine());
balance -= purchase; balance -= purchase;
Console.WriteLine($"Общая стоймость покупки {purchase} Остаток средств на балансе {balance}"); Console.WriteLine($"Общая стоимость покупки {purchase} Остаток средств на балансе {balance}");
} }
} }
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lesson4", "lesson4\lesson4.csproj", "{A3079F49-BE78-4B32-A983-6C04D045083B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3079F49-BE78-4B32-A983-6C04D045083B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3079F49-BE78-4B32-A983-6C04D045083B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3079F49-BE78-4B32-A983-6C04D045083B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3079F49-BE78-4B32-A983-6C04D045083B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+12
View File
@@ -0,0 +1,12 @@
namespace lesson4;
class Program
{
static void Main(string[] args)
{
string[] activeTeam = new string[3];
Console.WriteLine("РЕГИСТРАЦИЯ КОМАНДЫ\n");
activeTeam[0] = Console.ReadLine();
}
}
@@ -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>
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3", "3\3.csproj", "{3E2A654E-75FE-4BE6-90B3-635792DF4439}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E2A654E-75FE-4BE6-90B3-635792DF4439}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>_3</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+96
View File
@@ -0,0 +1,96 @@
using System;
namespace PokemonBattle
{
class Program
{
static void Main(string[] sender)
{
// задание 2
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;
}
// задание 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})\n");
// задание 3
while (pokemon1Hp > 0 && pokemon2Hp > 0)
{
Console.WriteLine($"--- Раунд {roundNumber} ---");
pokemon2Hp -= pokemon1Attack;
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
if (pokemon2Hp <= 0)
{
pokemon2Hp = 0;
Console.WriteLine($"{pokemon2Name} потерял сознание!\n");
break;
}
pokemon1Hp -= pokemon2Attack;
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
if (pokemon1Hp <= 0)
{
pokemon1Hp = 0;
Console.WriteLine($"{pokemon1Name} потерял сознание!\n");
break;
}
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}\n");
roundNumber++;
}
Console.WriteLine("БОЙ ОКОНЧЕН");
if (pokemon1Hp > 0)
{
Console.WriteLine($"Победитель: {pokemon1Name}!");
}
else
{
Console.WriteLine($"Победитель: {pokemon2Name}!");
}
}
}
}
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "4", "4\4.csproj", "{6FE6891D-041B-486B-BA18-61A98B2931EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FE6891D-041B-486B-BA18-61A98B2931EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FE6891D-041B-486B-BA18-61A98B2931EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FE6891D-041B-486B-BA18-61A98B2931EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FE6891D-041B-486B-BA18-61A98B2931EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>_4</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+53
View File
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
namespace PokemonLab4
{
class Program
{
static void Main(string[] args)
{
// задание 1
Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ===");
string[] activeTeam = new string[3];
for (int i = 0; i < activeTeam.Length; i++)
{
Console.Write($"Введите имя покемона №{i + 1}: ");
activeTeam[i] = Console.ReadLine();
}
Console.WriteLine("\n--- Ваша команда на этот бой ---");
Console.WriteLine($"1. {activeTeam[0]}");
Console.WriteLine($"2. {activeTeam[1]}");
Console.WriteLine($"3. {activeTeam[2]}");
Console.WriteLine();
// задание 2 и 3
Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ===");
List<string> backpack = new List<string>();
backpack.Add("Зелье HP");
backpack.Add("Покебол");
backpack.Add("Антидот");
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {backpack.Count}");
backpack.Remove("Покебол");
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {backpack.Count}\n");
// задание 3
Console.WriteLine("--- Содержимое вашей сумки ---");
foreach (string item in backpack)
{
Console.WriteLine($"[Предмет] -> {item}");
}
Console.WriteLine("=============================");
}
}
}
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{5BA785FD-F135-4D2D-95DA-E69D395AB140}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5BA785FD-F135-4D2D-95DA-E69D395AB140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BA785FD-F135-4D2D-95DA-E69D395AB140}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BA785FD-F135-4D2D-95DA-E69D395AB140}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BA785FD-F135-4D2D-95DA-E69D395AB140}.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,9 @@
namespace ConsoleApp1;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
+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", "{F58B28FA-A9CC-4F57-AE47-60682018140F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F58B28FA-A9CC-4F57-AE47-60682018140F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F58B28FA-A9CC-4F57-AE47-60682018140F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F58B28FA-A9CC-4F57-AE47-60682018140F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F58B28FA-A9CC-4F57-AE47-60682018140F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+54
View File
@@ -0,0 +1,54 @@
using System;
namespace LaboratoryWork5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
int pokemonHP = 20;
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
HealPokemon(ref pokemonHP);
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
Console.WriteLine("\n=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
string foundPokemon;
int pokemonLevel;
SearchBushes(out foundPokemon, out pokemonLevel);
Console.WriteLine("\n=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
double stadiumDifficulty = 1.5;
RegisterTournament(in stadiumDifficulty, "Булбазавр", "Чармандер");
Console.WriteLine("-----------------------------");
RegisterTournament(in stadiumDifficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
Console.WriteLine("=============================");
}
static void HealPokemon(ref int hp)
{
hp += 80;
Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
}
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
Random rand = new Random();
foundPokemon = "Пикачу";
pokemonLevel = rand.Next(1, 16);
Console.WriteLine("Вы зашли в высокую траву...");
Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!");
}
static void RegisterTournament(in double difficulty, params string[] participants)
{
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
Console.WriteLine("Список участников:");
foreach (string pokemon in participants)
{
Console.WriteLine($" * {pokemon}");
}
}
}
}
+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>
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-06", "lab-06\lab-06.csproj", "{B696010B-D447-40B4-ABF7-6FFBE791E429}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B696010B-D447-40B4-ABF7-6FFBE791E429}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B696010B-D447-40B4-ABF7-6FFBE791E429}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B696010B-D447-40B4-ABF7-6FFBE791E429}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B696010B-D447-40B4-ABF7-6FFBE791E429}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+127
View File
@@ -0,0 +1,127 @@
using System;
class Pokemon
{
private string name;
private int level;
private int hp;
public static int Count = 0;
public string Name
{
get { return name; }
set
{
if (value == "") name = "Безымянный";
else name = value;
}
}
public int Level
{
get { return level; }
set
{
if (value < 1) level = 1;
else if (value > 100) level = 100;
else level = value;
}
}
public int Hp
{
get { return hp; }
set
{
if (value < 0) hp = 0;
else if (value > 100) hp = 100;
else hp = value;
}
}
public Pokemon(string name, int level, int hp)
{
this.Name = name;
this.Level = level;
this.Hp = hp;
Count = Count + 1;
}
public Pokemon()
{
this.Name = "Безымянный";
this.Level = 1;
this.Hp = 100;
Count = Count + 1;
}
public void ShowInfo(int number)
{
Console.WriteLine($"{number}. Имя: {Name}, Уровень: {Level}, HP: {Hp}");
}
public void TakeDamage(int damage)
{
this.Hp = this.Hp - damage;
}
public void Heal()
{
this.Hp = 100;
}
public void Battle(Pokemon enemy)
{
Console.WriteLine($"{this.Name} (Ур. {this.Level}, HP {this.Hp}) против {enemy.Name} (Ур. {enemy.Level}, HP {enemy.Hp})");
if (this.Level >= enemy.Level)
{
Console.WriteLine($"{this.Name} побеждает! {enemy.Name} теряет {this.Level} HP.");
enemy.TakeDamage(this.Level);
Console.WriteLine($"Победитель: {this.Name}. Осталось HP: {this.Hp}");
Console.WriteLine($"Побеждённый: {enemy.Name}. Осталось HP: {enemy.Hp}");
}
else
{
Console.WriteLine($"{enemy.Name} побеждает! {this.Name} теряет {enemy.Level} HP.");
this.TakeDamage(enemy.Level);
Console.WriteLine($"Победитель: {enemy.Name}. Осталось HP: {enemy.Hp}");
Console.WriteLine($"Побеждённый: {this.Name}. Осталось HP: {this.Hp}");
}
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== ПОКЕДЕКС ===");
Pokemon pikachu = new Pokemon("Пикачу", 5, 100);
Pokemon squirtle = new Pokemon("Сквиртл", 7, 90);
pikachu.ShowInfo(1);
squirtle.ShowInfo(2);
Console.WriteLine("\n=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===");
Pokemon testPoke = new Pokemon("Чармандер", 10, 100);
Console.WriteLine("Попытка установить HP = -50...");
testPoke.Hp = -50;
Console.WriteLine($"Текущее HP: {testPoke.Hp} (защита сработала)");
testPoke.Hp = 100;
testPoke.TakeDamage(30);
Console.WriteLine($"Покемон получил 30 урона. HP: {testPoke.Hp}");
testPoke.Heal();
Console.WriteLine($"Покемон вылечился. HP: {testPoke.Hp}");
Console.WriteLine("\n=== ПОКЕДЕКС: СТАТИСТИКА ===");
Pokemon egg = new Pokemon();
Console.WriteLine($"Создано покемонов: {Pokemon.Count}");
Console.WriteLine("\n=== БИТВА ===");
pikachu.Battle(squirtle);
}
}
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>lab_06</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>