generated from admin/template
Merge branch 'main' of http://31.128.39.10:3000/polyphemus/prog-radzh #
Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
## input
|
||||
```csharp
|
||||
string pokemon1Name = "Пикачу";
|
||||
int pokemon1Hp = 50;
|
||||
int pokemon1Attack = 12;
|
||||
string pokemon2Name = "Булбазавр";
|
||||
int pokemon2Hp = 55;
|
||||
int pokemon2Attack = 10;
|
||||
int roundNumber = 1;
|
||||
```
|
||||
|
||||
## task 1
|
||||
```csharp
|
||||
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})");
|
||||
```
|
||||
|
||||
## task 2
|
||||
```csharp
|
||||
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);
|
||||
```
|
||||
|
||||
## task 3
|
||||
```csharp
|
||||
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}\n");
|
||||
roundNumber++;
|
||||
}
|
||||
|
||||
Console.WriteLine("\n--- Конец боя ---");
|
||||
if (pokemon1Hp > 0 && pokemon2Hp <= 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon1Name}!");
|
||||
}
|
||||
else if (pokemon2Hp > 0 && pokemon1Hp <= 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon2Name}!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Ничья!");
|
||||
}
|
||||
```
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\prog-radzh\\works\\Csharp\\lab-04\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{073D152A-0F08-4E68-927B-62FDC78E7819}|lab-04\\lab-04.csproj|c:\\prog-radzh\\works\\csharp\\lab-04\\lab-04\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{073D152A-0F08-4E68-927B-62FDC78E7819}|lab-04\\lab-04.csproj|solutionrelative:lab-04\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\prog-radzh\\works\\Csharp\\lab-04\\lab-04\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-04\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\Csharp\\lab-04\\lab-04\\Program.cs",
|
||||
"RelativeToolTip": "lab-04\\Program.cs",
|
||||
"ViewState": "AgIAACUAAAAAAAAAAAAQwCwAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-22T17:40:05.962Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\prog-radzh\\works\\Csharp\\lab-04\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{073D152A-0F08-4E68-927B-62FDC78E7819}|lab-04\\lab-04.csproj|c:\\prog-radzh\\works\\csharp\\lab-04\\lab-04\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{073D152A-0F08-4E68-927B-62FDC78E7819}|lab-04\\lab-04.csproj|solutionrelative:lab-04\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\prog-radzh\\works\\Csharp\\lab-04\\lab-04\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-04\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\Csharp\\lab-04\\lab-04\\Program.cs",
|
||||
"RelativeToolTip": "lab-04\\Program.cs",
|
||||
"ViewState": "AgIAACUAAAAAAAAAAAAQwCwAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-22T17:40:05.962Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
## task 1
|
||||
```csharp
|
||||
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();
|
||||
```
|
||||
|
||||
## task 2
|
||||
```csharp
|
||||
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}");
|
||||
```
|
||||
|
||||
## task 3
|
||||
```csharp
|
||||
Console.WriteLine("\n--- Содержимое вашей сумки ---");
|
||||
foreach (string item in backpack)
|
||||
{
|
||||
Console.WriteLine($"[Предмет] -> {item}");
|
||||
}
|
||||
|
||||
Console.WriteLine("=============================");
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.37628.2 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-04", "lab-04\lab-04.csproj", "{073D152A-0F08-4E68-927B-62FDC78E7819}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{073D152A-0F08-4E68-927B-62FDC78E7819}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{073D152A-0F08-4E68-927B-62FDC78E7819}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{073D152A-0F08-4E68-927B-62FDC78E7819}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{073D152A-0F08-4E68-927B-62FDC78E7819}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {272D78C9-5596-4B06-8EF3-3AE83481A54A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PokemonTrainerLab
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// task 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();
|
||||
|
||||
// task 2
|
||||
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}");
|
||||
|
||||
// task 3
|
||||
Console.WriteLine("\n--- Содержимое вашей сумки ---");
|
||||
foreach (string item in backpack)
|
||||
{
|
||||
Console.WriteLine($"[Предмет] -> {item}");
|
||||
}
|
||||
|
||||
Console.WriteLine("=============================");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<RootNamespace>lab_04</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user