add c lab
This commit is contained in:
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\\\u0421#-lab\\lab-01\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}|lab-01\\lab-01.csproj|c:\\prog-radzh\\works\\\u0441#-lab\\lab-01\\lab-01\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}|lab-01\\lab-01.csproj|solutionrelative:lab-01\\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\\\u0421#-lab\\lab-01\\lab-01\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-01\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-01\\lab-01\\Program.cs",
|
||||
"RelativeToolTip": "lab-01\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAIAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-05T18:08:25.89Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-01\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}|lab-01\\lab-01.csproj|c:\\prog-radzh\\works\\\u0441#-lab\\lab-01\\lab-01\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}|lab-01\\lab-01.csproj|solutionrelative:lab-01\\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\\\u0421#-lab\\lab-01\\lab-01\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-01\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-01\\lab-01\\Program.cs",
|
||||
"RelativeToolTip": "lab-01\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABYAAAAmAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-05T18:08:25.89Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Лабораторная работа №1
|
||||
|
||||
* **Студент:** [Масяк Роман Максимович]
|
||||
* **Вариант / Карточка:** [Введение в язык C#. Переменные, базовые типы данных и консольный ввод/вывод информации]
|
||||
|
||||
---
|
||||
|
||||
### task 1
|
||||
```csharp
|
||||
//task 1
|
||||
string pokemonName = "Чармандер";
|
||||
string elementType = "Огонь";
|
||||
int level = 1;
|
||||
int hp = 95;
|
||||
|
||||
Console.WriteLine($"=== БАЗА ДАННЫХ ПОКЕМОНОВ === \nПокемон: {pokemonName}\nСтихия: {elementType}\nУровень: {level} | HP:{hp}");
|
||||
```
|
||||
|
||||
### task 2
|
||||
```csharp
|
||||
//task 2
|
||||
string trainerName = Console.ReadLine();
|
||||
string pokemonName = Console.ReadLine();
|
||||
string elementType = Console.ReadLine();
|
||||
string regionName = Console.ReadLine();
|
||||
|
||||
Console.WriteLine($"Введите имя тренера: {trainerName}");
|
||||
Console.WriteLine($"Введите имя покемона: {pokemonName}");
|
||||
Console.WriteLine($"Введите стихию: {elementType}");
|
||||
Console.WriteLine($"Введите регион: {regionName}");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("****************************************");
|
||||
Console.WriteLine("ПАСПОРТ ПОКЕМОНА");
|
||||
Console.WriteLine($"Тренер: {trainerName} (Регион: {regionName})");
|
||||
Console.WriteLine($"Покемон: {pokemonName} [Стихия: {elementType}]");
|
||||
Console.WriteLine("****************************************");
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.37531.7 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-01", "lab-01\lab-01.csproj", "{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{38C86E38-EFCD-4B99-9271-15ED2E2D8CED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {73EB97D7-71EE-459D-BED7-CB7CF04DD45E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,27 @@
|
||||
//task 1
|
||||
|
||||
//string pokemonName = "Чармандер";
|
||||
//string elementType = "Огонь";
|
||||
//int level = 1;
|
||||
//int hp = 95;
|
||||
|
||||
//Console.WriteLine($"=== БАЗА ДАННЫХ ПОКЕМОНОВ === \nПокемон: {pokemonName}\nСтихия: {elementType}\nУровень: {level} | HP:{hp}");
|
||||
|
||||
//task 2
|
||||
|
||||
string trainerName = Console.ReadLine();
|
||||
string pokemonName = Console.ReadLine();
|
||||
string elementType = Console.ReadLine();
|
||||
string regionName = Console.ReadLine();
|
||||
|
||||
Console.WriteLine($"Введите имя тренера: {trainerName}");
|
||||
Console.WriteLine($"Введите имя покемона: {pokemonName}");
|
||||
Console.WriteLine($"Введите стихию: {elementType}");
|
||||
Console.WriteLine($"Введите регион: {regionName}");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("****************************************");
|
||||
Console.WriteLine("ПАСПОРТ ПОКЕМОНА");
|
||||
Console.WriteLine($"Тренер: {trainerName} (Регион: {regionName})");
|
||||
Console.WriteLine($"Покемон: {pokemonName} [Стихия: {elementType}]");
|
||||
Console.WriteLine("****************************************");
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>lab_01</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
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\\\u0421#-lab\\lab-02\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{1618B996-07F0-4089-B793-2F90075E414D}|lab-02\\lab-02.csproj|c:\\prog-radzh\\works\\\u0441#-lab\\lab-02\\lab-02\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{1618B996-07F0-4089-B793-2F90075E414D}|lab-02\\lab-02.csproj|solutionrelative:lab-02\\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\\\u0421#-lab\\lab-02\\lab-02\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-02\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-02\\lab-02\\Program.cs",
|
||||
"RelativeToolTip": "lab-02\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAEUAAAABAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-05T19:03:29.802Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-02\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{1618B996-07F0-4089-B793-2F90075E414D}|lab-02\\lab-02.csproj|c:\\prog-radzh\\works\\\u0441#-lab\\lab-02\\lab-02\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{1618B996-07F0-4089-B793-2F90075E414D}|lab-02\\lab-02.csproj|solutionrelative:lab-02\\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\\\u0421#-lab\\lab-02\\lab-02\\Program.cs",
|
||||
"RelativeDocumentMoniker": "lab-02\\Program.cs",
|
||||
"ToolTip": "C:\\prog-radzh\\works\\\u0421#-lab\\lab-02\\lab-02\\Program.cs*",
|
||||
"RelativeToolTip": "lab-02\\Program.cs*",
|
||||
"ViewState": "AgIAACsAAAAAAAAAAAAwwEUAAAABAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2026-09-05T19:03:29.802Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
# Лабораторная работа №2
|
||||
|
||||
* **Студент:** [Масяк Роман Максимович]
|
||||
* **Вариант / Карточка:** [БЛОК 1: Ввод данных и преобразование типов (int.Parse)]
|
||||
|
||||
---
|
||||
### task 1.1
|
||||
```csharp
|
||||
// task 1.1
|
||||
Console.WriteLine("=== Прокачка покемона ===");
|
||||
|
||||
Console.Write("Базовая атака: ");
|
||||
int damage = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.Write("Уровень: ");
|
||||
int lvl = int.Parse(Console.ReadLine());
|
||||
|
||||
int totalDamage = damage + (lvl * 5);
|
||||
|
||||
Console.WriteLine($"----- Итоговая атака -----\n----- {totalDamage} -----");
|
||||
```
|
||||
### task 1.2
|
||||
```csharp
|
||||
// task 1.2
|
||||
int balanceTrainer = 1500;
|
||||
int potionCost = 200;
|
||||
Console.WriteLine($"Баланс тренера: {balanceTrainer}");
|
||||
|
||||
Console.Write("Кол-во зелей: ");
|
||||
int amountPotion = int.Parse(Console.ReadLine());
|
||||
balanceTrainer -= amountPotion * potionCost;
|
||||
Console.WriteLine(balanceTrainer);
|
||||
```
|
||||
### task 2.1
|
||||
```csharp
|
||||
// task 2.1
|
||||
int hp = int.Parse(Console.ReadLine());
|
||||
|
||||
if (hp <= 0)
|
||||
{
|
||||
Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
|
||||
}
|
||||
|
||||
else if (1 <= hp && hp <= 20)
|
||||
{
|
||||
Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
|
||||
}
|
||||
else if (21 <= hp && hp <= 50)
|
||||
{
|
||||
Console.WriteLine("Покемон ранен, будьте осторожны");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Покемон полон сил и готов к бою!");
|
||||
}
|
||||
```
|
||||
### task 2.2
|
||||
```csharp
|
||||
// task 2.2
|
||||
Console.WriteLine("1:— Атака \n2:— Инвентарь \n3:— Сменить покемона \n4:— Побег");
|
||||
|
||||
Console.Write("Выбор действий:");
|
||||
int num = int.Parse(Console.ReadLine());
|
||||
|
||||
switch (num)
|
||||
{
|
||||
case 1:
|
||||
Console.WriteLine("Покемон наносит быстрый удар");
|
||||
break;
|
||||
case 2:
|
||||
Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
|
||||
break;
|
||||
case 3:
|
||||
Console.WriteLine("Вы отозвали покемона и выпустили нового!");
|
||||
break;
|
||||
case 4:
|
||||
Console.WriteLine("Вы успешно сбежали из боя!");
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
|
||||
break;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.37531.7 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-02", "lab-02\lab-02.csproj", "{1618B996-07F0-4089-B793-2F90075E414D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1618B996-07F0-4089-B793-2F90075E414D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1618B996-07F0-4089-B793-2F90075E414D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1618B996-07F0-4089-B793-2F90075E414D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1618B996-07F0-4089-B793-2F90075E414D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {58730CCD-9E8F-4FE4-8515-0B652CA00D3C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,70 @@
|
||||
//// task 1.1
|
||||
//Console.WriteLine("=== Прокачка покемона ===");
|
||||
|
||||
//Console.Write("Базовая атака: ");
|
||||
//int damage = int.Parse(Console.ReadLine());
|
||||
|
||||
//Console.Write("Уровень: ");
|
||||
//int lvl = int.Parse(Console.ReadLine());
|
||||
|
||||
//int totalDamage = damage + (lvl * 5);
|
||||
|
||||
//Console.WriteLine($"----- Итоговая атака -----\n----- {totalDamage} -----");
|
||||
|
||||
|
||||
//// task 1.2
|
||||
//int balanceTrainer = 1500;
|
||||
//int potionCost = 200;
|
||||
//Console.WriteLine($"Баланс тренера: {balanceTrainer}");
|
||||
|
||||
//Console.Write("Кол-во зелей: ");
|
||||
//int amountPotion = int.Parse(Console.ReadLine());
|
||||
//balanceTrainer -= amountPotion * potionCost;
|
||||
//Console.WriteLine(balanceTrainer);
|
||||
|
||||
|
||||
//// task 2.1
|
||||
//int hp = int.Parse(Console.ReadLine());
|
||||
|
||||
//if (hp <= 0)
|
||||
//{
|
||||
// Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
|
||||
//}
|
||||
|
||||
//else if (1 <= hp && hp <= 20)
|
||||
//{
|
||||
// Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
|
||||
//}
|
||||
//else if (21 <= hp && hp <= 50)
|
||||
//{
|
||||
// Console.WriteLine("Покемон ранен, будьте осторожны");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Console.WriteLine("Покемон полон сил и готов к бою!");
|
||||
//}
|
||||
|
||||
//// task 2.2
|
||||
//Console.WriteLine("1:— Атака \n2:— Инвентарь \n3:— Сменить покемона \n4:— Побег");
|
||||
|
||||
//Console.Write("Выбор действий:");
|
||||
//int num = int.Parse(Console.ReadLine());
|
||||
|
||||
//switch (num)
|
||||
//{
|
||||
// case 1:
|
||||
// Console.WriteLine("Покемон наносит быстрый удар");
|
||||
// break;
|
||||
// case 2:
|
||||
// Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
|
||||
// break;
|
||||
// case 3:
|
||||
// Console.WriteLine("Вы отозвали покемона и выпустили нового!");
|
||||
// break;
|
||||
// case 4:
|
||||
// Console.WriteLine("Вы успешно сбежали из боя!");
|
||||
// break;
|
||||
// default:
|
||||
// Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
|
||||
// break;
|
||||
//}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<RootNamespace>lab_02</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
//task 1
|
||||
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}");
|
||||
|
||||
/*
|
||||
//task 2
|
||||
int command;
|
||||
bool isValid;
|
||||
do
|
||||
{
|
||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||
command = int.Parse(Console.ReadLine());
|
||||
isValid = (command == 1 || command == 0);
|
||||
if (!isValid)
|
||||
{
|
||||
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||
}
|
||||
|
||||
} while (!isValid);
|
||||
if (command == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Бой начался! Удачи!");
|
||||
|
||||
|
||||
// task 3
|
||||
using System;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
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}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user