generated from admin/template
lab-04, lab-05 done
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using HelpMethods;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Action1();
|
||||
SystemHelp.Waiting(true);
|
||||
|
||||
|
||||
|
||||
var backpack = CreateBackpack();
|
||||
FillBackpack(backpack);
|
||||
ShowItemsInBackpack(backpack);
|
||||
|
||||
UseItem(backpack);
|
||||
ShowItemsInBackpack(backpack);
|
||||
|
||||
SystemHelp.Waiting(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Методы для задания №1.
|
||||
/// </summary>
|
||||
static void Action1() => ShowCommand(CommandRegistration());
|
||||
static string[] CommandRegistration()
|
||||
{
|
||||
const byte COUNT = 3;
|
||||
var pokemons = new string[COUNT];
|
||||
|
||||
Console.WriteLine("=== Command registration ===");
|
||||
for (byte pokemon = 0; pokemon < COUNT; pokemon++)
|
||||
{
|
||||
Console.Write($"Pokemon №{pokemon + 1}: ");
|
||||
pokemons[pokemon] = Console.ReadLine() ?? $"Pokemon{pokemon + 1}";
|
||||
|
||||
if(pokemons[pokemon] == String.Empty)
|
||||
pokemons[pokemon] = $"Pokemon{pokemon + 1}";
|
||||
}
|
||||
StringHelp.Br();
|
||||
|
||||
return pokemons;
|
||||
}
|
||||
static void ShowCommand(string[] pokemons)
|
||||
{
|
||||
byte counter = 1;
|
||||
|
||||
Console.WriteLine("=== Your command ===");
|
||||
foreach(var pokemon in pokemons)
|
||||
Console.WriteLine($"{counter++}. {pokemon}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Методы для задания №2.
|
||||
/// </summary>
|
||||
static List<string> CreateBackpack() => new List<string>();
|
||||
static void FillBackpack(List<string> backpack)
|
||||
{
|
||||
string[] initialItems =
|
||||
{
|
||||
"Зелье HP",
|
||||
"Покебол",
|
||||
"Антидот",
|
||||
};
|
||||
|
||||
foreach (var item in initialItems)
|
||||
backpack.Add(item);
|
||||
|
||||
Console.WriteLine("The backpack was filled!\n");
|
||||
}
|
||||
static void ShowItemsInBackpack(List<string> backpack)
|
||||
{
|
||||
byte counter = 1;
|
||||
|
||||
Console.WriteLine("=== Items ===");
|
||||
foreach(var item in backpack)
|
||||
Console.WriteLine($"{counter++}. {item}");
|
||||
|
||||
Console.WriteLine($"\nItems in the backpack: {backpack.Count}\n");
|
||||
}
|
||||
static void UseItem(List<string> backpack)
|
||||
{
|
||||
Console.Write("What item do you want to use?\nItem: ");
|
||||
string targetItem = Console.ReadLine().Trim();
|
||||
StringHelp.Br();
|
||||
|
||||
if(!backpack.Exists(item => item == targetItem))
|
||||
{
|
||||
Console.WriteLine($"The item \"{targetItem}\" was not foumd.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
backpack.Remove(targetItem);
|
||||
Console.WriteLine($"You use {targetItem}!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0580ACC5-9C57-48B6-A97B-75103119F024}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Test</RootNamespace>
|
||||
<AssemblyName>Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MyDll, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\MyDll.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using HelpMethods;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static Random rand = new Random();
|
||||
static void Main(string[] args)
|
||||
{
|
||||
short pokemonHp = 20;
|
||||
string pokemon;
|
||||
byte pokemonLevel;
|
||||
double difficulty = 1.5;
|
||||
|
||||
|
||||
Console.WriteLine($"Hp befor: {pokemonHp} HP\n");
|
||||
HealPokemon(ref pokemonHp);
|
||||
Console.WriteLine($"Hp after: {pokemonHp} HP\n");
|
||||
|
||||
|
||||
SearchBushes(out pokemon, out pokemonLevel);
|
||||
|
||||
RegisterTournament(difficulty, "p1", "p2");
|
||||
RegisterTournament(difficulty, "p1", "p2", "p3", "p4");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод для задания №1.
|
||||
/// </summary>
|
||||
static void HealPokemon(ref short hp)
|
||||
{
|
||||
Console.WriteLine("Healed!");
|
||||
hp += 80;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод для задания №2.
|
||||
/// </summary>
|
||||
static void SearchBushes(out string foundPokemon, out byte pokemonLevel)
|
||||
{
|
||||
string[] wildPokemons =
|
||||
{
|
||||
"Pokemon1",
|
||||
"Pokemon2",
|
||||
"Pokemon3",
|
||||
"Pokemon4",
|
||||
"Пикачу",
|
||||
};
|
||||
|
||||
foundPokemon = wildPokemons[rand.Next(wildPokemons.Length)];
|
||||
pokemonLevel = (byte)rand.Next(1, 16);
|
||||
|
||||
Console.WriteLine(
|
||||
$@"=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===
|
||||
Вы зашли в высокую траву...
|
||||
Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!
|
||||
");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод для задания №3.
|
||||
/// </summary>
|
||||
static void RegisterTournament(in double difficulty, params string[] participants)
|
||||
{
|
||||
byte counter = 1;
|
||||
|
||||
Console.WriteLine($"=== Registered Pokemons ===\nDifficulty: {difficulty}");
|
||||
foreach(string participant in participants)
|
||||
Console.WriteLine($"Pkemon №{counter++}: {participant}");
|
||||
|
||||
StringHelp.Br();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0580ACC5-9C57-48B6-A97B-75103119F024}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Test</RootNamespace>
|
||||
<AssemblyName>Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MyDll, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\MyDll.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
Reference in New Issue
Block a user