generated from admin/template
edit lab-03
This commit is contained in:
@@ -1,11 +1,4 @@
|
|||||||
using System;
|
internal class Program
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace lesson3
|
|
||||||
{
|
|
||||||
internal class Program
|
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -16,26 +9,23 @@ namespace lesson3
|
|||||||
int pokemon2Hp = 55;
|
int pokemon2Hp = 55;
|
||||||
int pokemon2Attack = 10;
|
int pokemon2Attack = 10;
|
||||||
int roundNumber = 1;
|
int roundNumber = 1;
|
||||||
|
int actionChoise;
|
||||||
//задание 2
|
//задание 2
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||||
int check = int.Parse(Console.ReadLine());
|
actionChoise = int.Parse(Console.ReadLine());
|
||||||
if (check == 0)
|
if (actionChoise != 1 && actionChoise != 0)
|
||||||
|
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||||
|
}while (actionChoise != 1 && actionChoise != 0);
|
||||||
|
if (actionChoise == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nВы отменили бой!");
|
Console.WriteLine("\nВы отменили бой!");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (check == 1)
|
else if (actionChoise == 1)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nВы приняли бой!");
|
Console.WriteLine("\nВы приняли бой!");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Console.WriteLine("\nНекорректная команда! Попробуйте снова.");
|
|
||||||
}while (true);
|
|
||||||
|
|
||||||
//задание 1
|
//задание 1
|
||||||
Console.WriteLine("Приготовьтесь!");
|
Console.WriteLine("Приготовьтесь!");
|
||||||
for (int i = 3; i > 0; i--)
|
for (int i = 3; i > 0; i--)
|
||||||
@@ -46,13 +36,11 @@ namespace lesson3
|
|||||||
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//задание 3
|
//задание 3
|
||||||
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
Console.WriteLine($"\n--- Раунд {roundNumber} ---");
|
||||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
pokemon2Hp -= pokemon1Attack;
|
pokemon2Hp -= pokemon1Attack;
|
||||||
if (pokemon2Hp <= 0)
|
if (pokemon2Hp <= 0)
|
||||||
@@ -74,12 +62,9 @@ namespace lesson3
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
|
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
|
||||||
Console.WriteLine();
|
|
||||||
roundNumber ++;
|
roundNumber ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
+8
-11
@@ -19,25 +19,23 @@
|
|||||||
int pokemon2Hp = 55;
|
int pokemon2Hp = 55;
|
||||||
int pokemon2Attack = 10;
|
int pokemon2Attack = 10;
|
||||||
int roundNumber = 1;
|
int roundNumber = 1;
|
||||||
|
int actionChoise;
|
||||||
//задание 2
|
//задание 2
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||||
int check = int.Parse(Console.ReadLine());
|
actionChoise = int.Parse(Console.ReadLine());
|
||||||
if (check == 0)
|
if (actionChoise != 1 && actionChoise != 0)
|
||||||
|
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||||
|
}while (actionChoise != 1 && actionChoise != 0);
|
||||||
|
if (actionChoise == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nВы отменили бой!");
|
Console.WriteLine("\nВы отменили бой!");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (check == 1)
|
else if (actionChoise == 1)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nВы приняли бой!");
|
Console.WriteLine("\nВы приняли бой!");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Console.WriteLine("\nНекорректная команда! Попробуйте снова.");
|
|
||||||
}while (true);
|
|
||||||
//задание 1
|
//задание 1
|
||||||
Console.WriteLine("Приготовьтесь!");
|
Console.WriteLine("Приготовьтесь!");
|
||||||
for (int i = 3; i > 0; i--)
|
for (int i = 3; i > 0; i--)
|
||||||
@@ -54,7 +52,7 @@
|
|||||||
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
Console.WriteLine($"\n--- Раунд {roundNumber} ---");
|
||||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
pokemon2Hp -= pokemon1Attack;
|
pokemon2Hp -= pokemon1Attack;
|
||||||
if (pokemon2Hp <= 0)
|
if (pokemon2Hp <= 0)
|
||||||
@@ -76,7 +74,6 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
|
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
|
||||||
Console.WriteLine();
|
|
||||||
roundNumber ++;
|
roundNumber ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-03", "lab-03.csproj", "{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B6FA26AE-3C54-4581-A137-151FA8AB7EB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Reference in New Issue
Block a user