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.
Reference in New Issue
Block a user