generated from admin/template
lab-03
This commit is contained in:
@@ -7,12 +7,6 @@
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
// Самая важная часть реализации (методы, структуры, логика)
|
||||
public class Card
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Hp { get; set; }
|
||||
}
|
||||
|
||||
using System;
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
# Лабораторная работа №3
|
||||
|
||||
* **Студент:** [Пузанова Анна Андреевна]
|
||||
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||
|
||||
---
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
using System;
|
||||
|
||||
namespace lab03
|
||||
{
|
||||
class lab03
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Console.WriteLine("1 ЗАДАНИЕ");
|
||||
// string pokemon1Name = "Пикачу";
|
||||
// int pokemon1Hp = 50;
|
||||
// int pokemon1Attack = 12;
|
||||
// string pokemon2Name = "Булбазавр";
|
||||
//int pokemon2Hp = 55;
|
||||
// int pokemon2Attack = 10;
|
||||
// int roundNumber = 1;
|
||||
// for (int i = 3; i > 0 ; i--)
|
||||
// {
|
||||
// Console.WriteLine($"{i}..");
|
||||
// }
|
||||
|
||||
// Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
|
||||
// Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("2 ЗАДАНИЕ");
|
||||
int choice;
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||
choice = int.Parse(Console.ReadLine());
|
||||
|
||||
if (choice != 1 && choice != 0)
|
||||
{
|
||||
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||
}
|
||||
} while (choice != 1 && choice != 0);
|
||||
|
||||
if (choice == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("3 ЗАДАНИЕ");
|
||||
string pokemon1Name = "Пикачу";
|
||||
string pokemon2Name = "Булбазавр";
|
||||
int pokemon1Attack = 12;
|
||||
int pokemon2Attack = 10;
|
||||
int pokemon1Hp = 40;
|
||||
int pokemon2Hp = 43;
|
||||
int roundNumber = 1;
|
||||
|
||||
while
|
||||
if (pokemon1Hp > pokemon2Hp)
|
||||
{
|
||||
Console.WriteLine($"Победитель:{pokemon1Name}");
|
||||
}
|
||||
else Console.WriteLine($"Победитель:{pokemon2Name}");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||
Console.WriteLine($"Итог раунда: Пикачу HP: {pokemon1Hp} | Булбазавр HP: {pokemon2Hp}");
|
||||
|
||||
Console.WriteLine ($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine("Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine(" Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine("Итог раунда: Пикачу HP: 30 | Булбазавр HP: 31");
|
||||
|
||||
Console.WriteLine ($"--- Раунд {roundNumber} ---");;
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine(" Итог раунда: Пикачу HP: 20 | Булбазавр HP: 19");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine("Итог раунда: Пикачу HP: 10 | Булбазавр HP: 7");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр потерял сознание!");
|
||||
|
||||
Console.WriteLine(" === БОЙ ОКОНЧЕН ===");
|
||||
Console.WriteLine(" Победитель: Пикачу!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1 ЗАДАНИЕ
|
||||
3..
|
||||
2..
|
||||
1..
|
||||
=== БОЙ НАЧИНАЕТСЯ ===
|
||||
Пикачу (HP: 50 | Атака: 12) VS Булбазавр (HP: 55 | Атака: 10)
|
||||
2 ЗАДАНИЕ
|
||||
Готовы начать бой? (1 - Да, 0 - Нет): 5
|
||||
Некорректная команда! Попробуйте снова.
|
||||
Готовы начать бой? (1 - Да, 0 - Нет): 0
|
||||
Вы отменили бой!
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-03", "lab-03\lab-03.csproj", "{7B515140-F7D5-450D-A672-9BB836357A9B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7B515140-F7D5-450D-A672-9BB836357A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B515140-F7D5-450D-A672-9BB836357A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B515140-F7D5-450D-A672-9BB836357A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B515140-F7D5-450D-A672-9BB836357A9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
|
||||
namespace lab03
|
||||
{
|
||||
class lab03
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Console.WriteLine("1 ЗАДАНИЕ");
|
||||
// string pokemon1Name = "Пикачу";
|
||||
// int pokemon1Hp = 50;
|
||||
// int pokemon1Attack = 12;
|
||||
// string pokemon2Name = "Булбазавр";
|
||||
//int pokemon2Hp = 55;
|
||||
// int pokemon2Attack = 10;
|
||||
// int roundNumber = 1;
|
||||
// for (int i = 3; i > 0 ; i--)
|
||||
// {
|
||||
// Console.WriteLine($"{i}..");
|
||||
// }
|
||||
|
||||
// Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
|
||||
// Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("2 ЗАДАНИЕ");
|
||||
int choice;
|
||||
|
||||
do
|
||||
{
|
||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||
choice = int.Parse(Console.ReadLine());
|
||||
|
||||
if (choice != 1 && choice != 0)
|
||||
{
|
||||
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||
}
|
||||
} while (choice != 1 && choice != 0);
|
||||
|
||||
if (choice == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("3 ЗАДАНИЕ");
|
||||
string pokemon1Name = "Пикачу";
|
||||
string pokemon2Name = "Булбазавр";
|
||||
int pokemon1Attack = 12;
|
||||
int pokemon2Attack = 10;
|
||||
int pokemon1Hp = 40;
|
||||
int pokemon2Hp = 43;
|
||||
int roundNumber = 1;
|
||||
|
||||
while
|
||||
if (pokemon1Hp > pokemon2Hp)
|
||||
{
|
||||
Console.WriteLine($"Победитель:{pokemon1Name}");
|
||||
}
|
||||
else Console.WriteLine($"Победитель:{pokemon2Name}");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||
Console.WriteLine($"Итог раунда: Пикачу HP: {pokemon1Hp} | Булбазавр HP: {pokemon2Hp}");
|
||||
|
||||
Console.WriteLine ($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine("Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine(" Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine("Итог раунда: Пикачу HP: 30 | Булбазавр HP: 31");
|
||||
|
||||
Console.WriteLine ($"--- Раунд {roundNumber} ---");;
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine(" Итог раунда: Пикачу HP: 20 | Булбазавр HP: 19");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр наносит 10 урона по Пикачу!");
|
||||
Console.WriteLine("Итог раунда: Пикачу HP: 10 | Булбазавр HP: 7");
|
||||
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
Console.WriteLine(" Пикачу наносит 12 урона по Булбазавр!");
|
||||
Console.WriteLine("Булбазавр потерял сознание!");
|
||||
|
||||
Console.WriteLine(" === БОЙ ОКОНЧЕН ===");
|
||||
Console.WriteLine(" Победитель: Пикачу!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>lab_03</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user