generated from admin/template
lab-06
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-01", "lab-01\lab-01.csproj", "{BB50D7B0-E655-40BA-8766-BFEAA1A2D5DC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BB50D7B0-E655-40BA-8766-BFEAA1A2D5DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BB50D7B0-E655-40BA-8766-BFEAA1A2D5DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BB50D7B0-E655-40BA-8766-BFEAA1A2D5DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BB50D7B0-E655-40BA-8766-BFEAA1A2D5DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,52 @@
|
||||
class PokemonStage
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string RequiredLevel { get; set; }
|
||||
|
||||
public PokemonStage(string name, string type, string requiredLevel)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
RequiredLevel = requiredLevel;
|
||||
}
|
||||
|
||||
public void ShowInfo()
|
||||
{
|
||||
Console.WriteLine($"Имя: {Name}, Тип: {Type}, Уровень эвлюции: {RequiredLevel}");
|
||||
}
|
||||
}
|
||||
|
||||
class EvolutionNode
|
||||
{
|
||||
public PokemonStage Data;
|
||||
public EvolutionNode Next;
|
||||
|
||||
public EvolutionNode(PokemonStage data)
|
||||
{
|
||||
Data = data;
|
||||
Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
class EvolutionLine
|
||||
{
|
||||
public EvolutionNode Head;
|
||||
public EvolutionNode Tail;
|
||||
public int Count;
|
||||
|
||||
AddFirst(PokemonStage stage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AddLast(PokemonStage stage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PrintAll()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>lab_01</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@Pokemon_HostAddress = http://localhost:5288
|
||||
|
||||
GET {{Pokemon_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,41 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast");
|
||||
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5288",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7187;http://localhost:5288",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
using PokedexApi.Models;
|
||||
|
||||
namespace PokedexApi.Storage;
|
||||
|
||||
public class PokemonStorage
|
||||
{
|
||||
public PokemonStorage()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Pokemon_0._1</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace PokedexApi.Models;
|
||||
|
||||
public record Pokemon(int Id, string Name, string Type, int Level);
|
||||
|
||||
public record PokemonInput(string Name, string Type, int Level);
|
||||
|
||||
public record LevelUpdate(int Level);
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-02", "lab-02\lab-02.csproj", "{693A9649-443F-4CC8-B8BA-EB460AC8D70E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace PokedexApi.Models;
|
||||
|
||||
public record Pokemon(int Id, string Name, string Type, int Level);
|
||||
|
||||
public record PokemonInput(string Name, string Type, int Level);
|
||||
|
||||
public record LevelUpdate(int Level);
|
||||
@@ -0,0 +1,12 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5014",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7036;http://localhost:5014",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using PokedexApi.Models;
|
||||
|
||||
namespace PokedexApi.Storage;
|
||||
|
||||
public class PokemonStorage
|
||||
{
|
||||
private List<Pokemon> _pokemons = new List<Pokemon>
|
||||
{
|
||||
new Pokemon(1, "Pikachu", "Electric", 12),
|
||||
new Pokemon(2, "Charmander", "Fire", 8),
|
||||
new Pokemon(3, "Squirtle", "Water", 10)
|
||||
};
|
||||
|
||||
public List<Pokemon> GetAll()
|
||||
{
|
||||
return new List<Pokemon>(_pokemons);
|
||||
}
|
||||
|
||||
public Pokemon? GetById(int id)
|
||||
{
|
||||
return _pokemons.FirstOrDefault(p => p.Id == id);
|
||||
}
|
||||
|
||||
public List<Pokemon> Filter(string? type, int? level)
|
||||
{
|
||||
return _pokemons.Where(p => p.Type == type || p.Level == level).ToList();
|
||||
}
|
||||
public List<Pokemon> SearchByName(string query)
|
||||
{
|
||||
return _pokemons.Where(p => p.Name.Contains(query)).ToList();
|
||||
}
|
||||
public Pokemon Add(PokedexInput)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>lab_02</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Endpoints\" />
|
||||
<Folder Include="Validation_0.1\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@lab_02_HostAddress = http://localhost:5014
|
||||
|
||||
GET {{lab_02_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,32 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Kotlin ###
|
||||
.kotlin
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
@@ -0,0 +1,11 @@
|
||||
fun calcDamage(power: Int, multiplier: Double = 1.0): Double = (power * multiplier).toInt().toDouble()
|
||||
|
||||
fun checkStatus(hp: Int): String {
|
||||
if (hp > 0) return "В строю"
|
||||
else return "Нокаут"
|
||||
}
|
||||
|
||||
fun printBattleLog(attacker: String, defender: String, damage: Int){
|
||||
print("=== ИНИЦИАЛИЗАЦИЯ БОЯ ===\nВведите имя вашего Покемона: Pikachu\nВведите стартовое HP (по умолчанию 60): 60")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user