generated from admin/template
Merge branch 'main' of https://git.ktgs.ru/koshkakartoshka300/prog-puzanova
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
|||||||
|
# ==========================================
|
||||||
|
# IDE & Editors (JetBrains: Rider, IDEA, Android Studio)
|
||||||
|
# ==========================================
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
*.ipr
|
||||||
|
.vscode/
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# Database Tools (DBeaver)
|
||||||
|
# ==========================================
|
||||||
|
.dbeaver/
|
||||||
|
.eclipse/
|
||||||
|
*.dbeaver-data/
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# C# / .NET / Visual Studio / Rider builds
|
||||||
|
# ==========================================
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
out/
|
||||||
|
[D-d]ebug/
|
||||||
|
[R-r]elease/
|
||||||
|
*.userprefs
|
||||||
|
*.pidb
|
||||||
|
*.versioncontrol
|
||||||
|
*.csproj.user
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# Android Studio / Gradle / Kotlin
|
||||||
|
# ==========================================
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
local.properties
|
||||||
|
.navigation/
|
||||||
|
captures/
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx/
|
||||||
|
*.apk
|
||||||
|
*.aab
|
||||||
|
*.keystore
|
||||||
|
*.jks
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# OS Generated Files & Logs
|
||||||
|
# ==========================================
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# Студент: [Пузанова Анна Андреевна]
|
||||||
|
* **Группа:** [228]
|
||||||
|
* **Курс:** [2]
|
||||||
|
|
||||||
|
## Список работ
|
||||||
|
|
||||||
|
### Разработка на C#
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | Лабораторная работа C# №1 | [Перейти](./works/CSharp/lab-01) | Завершено |
|
||||||
|
| 02 | Лабораторная работа C# №2 | [Перейти](./works/CSharp/lab-02) | Завершено |
|
||||||
|
| 03 | Лабораторная работа C# №3 | [Перейти](./works/CSharp/lab-03) | Завершено |
|
||||||
|
| 04 | Лабораторная работа C# №4 | [Перейти](./works/CSharp/lab-04) | Завершено |
|
||||||
|
| 05 | Лабораторная работа C# №5 | [Перейти](./works/CSharp/lab-05) | Завершено |
|
||||||
|
| 06 | Лабораторная работа C# №6 | [Перейти](./works/CSharp/lab-06) | Завершено |
|
||||||
|
| 07 | Лабораторная работа C# №7 | [Перейти](./works/CSharp/lab-07) | НЕ Завершено |
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | STAGE C# №1 | [Перейти](./works/CSharp/stage1) | Завершено |
|
||||||
|
| 02 | STAGE C# №2 | [Перейти](./works/CSharp/stage2) | Завершено |
|
||||||
|
| 03 | STAGE C# №3 | [Перейти](./works/CSharp/stage3) | Завершено |
|
||||||
|
---
|
||||||
|
|
||||||
|
### Разработка на Kotlin
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | Лабораторная работа Kotlin №1 | [Перейти](./works/Kotlin/works/lab-01) | Завершено |
|
||||||
|
| 02 | Лабораторная работа Kotlin №2 | [Перейти](./works/Kotlin/works/lab-02) | Завершено |
|
||||||
|
| 03 | Лабораторная работа Kotlin №3 | [Перейти](./works/Kotlin/works/lab-03) | Завершено |
|
||||||
|
| 04 | Лабораторная работа Kotlin №4 | [Перейти](./works/Kotlin/works/lab-04) | Завершено |
|
||||||
|
| 05 | Лабораторная работа Kotlin №5 | [Перейти](./works/Kotlin/works/lab-05) | Завершено |
|
||||||
|
| 06 | Лабораторная работа Kotlin №6 | [Перейти](./works/Kotlin/works/lab-06) | Завершено |
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | STAGE Kotlin №1 | [Перейти](./works/Kotlin/works/stage1) | Завершено |
|
||||||
|
| 02 | STAGE Kotlin №2 | [Перейти](./works/Kotlin/works/stage2) | Завершено |
|
||||||
|
| 03 | STAGE Kotlin №3 | [Перейти](./works/Kotlin/works/stage3) | НЕ завершено |
|
||||||
|
---
|
||||||
|
|
||||||
|
### Системное программирование
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | Практическая работа №1 | [Перейти](./works/SysProg/ПЗ_1) | НЕ завершено |
|
||||||
|
| 02 | Практическая работа №2 | [Перейти](./works/SysProg/ПЗ_2) | НЕ завершено |
|
||||||
|
---
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
| № | Наименование работы | Ссылка | Статус |
|
||||||
|
| :-: | :--- | :-: | :-: |
|
||||||
|
| 01 | Практическая работа №1 | [Перейти](./works/API/lab-01) | НЕ завершено |
|
||||||
|
| 02 | Практическая работа №2 | [Перейти](./works/API/lab-02) | НЕ завершено |
|
||||||
|
---
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi2", "PokedexApi2\PokedexApi2.csproj", "{726EA966-3EC2-4E25-9DC9-5C82383F659B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
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,17 @@
|
|||||||
|
<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>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Endpoints\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@PokedexApi2_HostAddress = http://localhost:5189
|
||||||
|
|
||||||
|
GET {{PokedexApi2_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using PokedexApi.Models;
|
||||||
|
|
||||||
|
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:5189",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "https://localhost:7085;http://localhost:5189",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
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)
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly object _lock = new object();
|
||||||
|
|
||||||
|
public void DoSomething()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
// этот блок выполняет только один поток за раз
|
||||||
|
// остальные ждут, пока он выйдет
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new Pokemon(1, "Pikachu", ...)
|
||||||
|
private readonly object _lock = new object();
|
||||||
|
|
||||||
|
// TODO 3: реализуй метод GetAll()
|
||||||
|
// TODO 4: реализуй метод GetById(int id)
|
||||||
|
// TODO 5: реализуй метод Filter(string? type, int? minLevel)
|
||||||
|
if (type != null && p.Type != type) continue;
|
||||||
|
if (minLevel != null && p.Level < minLevel) continue;
|
||||||
|
result.Add(p);
|
||||||
|
// TODO 6: реализуй метод SearchByName(string query)
|
||||||
|
// TODO 7: реализуй метод Add(PokemonInput input)
|
||||||
|
int newId = 1;
|
||||||
|
foreach (var p in _pokemons)
|
||||||
|
{
|
||||||
|
if (p.Id >= newId) newId = p.Id + 1;
|
||||||
|
}
|
||||||
|
new Pokemon(newId, input.Name, input.Type, input.Level)
|
||||||
|
|
||||||
|
// TODO 8: реализуй метод Update(int id, PokemonInput input)
|
||||||
|
// TODO 9: реализуй метод UpdateLevel(int id, int level)
|
||||||
|
// TODO 10: реализуй метод Delete(int id)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PokedexApi2.Validation;
|
||||||
|
|
||||||
|
public interface PokemonStorage
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,9 @@
|
|||||||
|
# Secrets
|
||||||
|
.env*
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
info:
|
||||||
|
name: "1"
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: https://pokeapi.co/api/v2/pokemon/pikachu
|
||||||
|
params:
|
||||||
|
- name: ""
|
||||||
|
value: ""
|
||||||
|
type: query
|
||||||
|
description: Получить покемона по имени (GET)
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
info:
|
||||||
|
name: "2"
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: https://pokeapi.co/api/v2/pokemon/25
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
info:
|
||||||
|
name: "3"
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: " https://pokeapi.co/api/v2/pokemon?limit=5&offset=0"
|
||||||
|
params:
|
||||||
|
- name: limit
|
||||||
|
value: "5"
|
||||||
|
type: query
|
||||||
|
- name: offset
|
||||||
|
value: "0"
|
||||||
|
type: query
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
info:
|
||||||
|
name: "4"
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: https://pokeapi.co/api/v2/type/electric
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
info:
|
||||||
|
name: "5"
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: |-
|
||||||
|
POST https://jsonplaceholder.typicode.com/posts
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"title": "Мой первый покемон",
|
||||||
|
"body": "Поймал Пикачу!",
|
||||||
|
"userId": 1
|
||||||
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
opencollection: 1.0.0
|
||||||
|
|
||||||
|
info:
|
||||||
|
name: Lab1 — PokeAPI
|
||||||
|
bundled: false
|
||||||
|
extensions:
|
||||||
|
bruno:
|
||||||
|
ignore:
|
||||||
|
- node_modules
|
||||||
|
- .git
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi1", "PokedexApi1\PokedexApi1.csproj", "{BC657A49-E88A-47A7-AD2C-E00C6BDEF14D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{BC657A49-E88A-47A7-AD2C-E00C6BDEF14D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BC657A49-E88A-47A7-AD2C-E00C6BDEF14D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BC657A49-E88A-47A7-AD2C-E00C6BDEF14D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BC657A49-E88A-47A7-AD2C-E00C6BDEF14D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<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"/>
|
||||||
|
<PackageReference Include="Scalar.AspNetCore" Version="2.18.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@PokedexApi1_HostAddress = http://localhost:5104
|
||||||
|
|
||||||
|
GET {{PokedexApi1_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
using Scalar.AspNetCore;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddOpenApi();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
var pokemons = new List<Pokemon>
|
||||||
|
{
|
||||||
|
new(1, "Pikachu", "Electric", 12),
|
||||||
|
new(2, "Charmander", "Fire", 8),
|
||||||
|
new(3, "Squirtle", "Water", 10)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.MapOpenApi();
|
||||||
|
app.MapScalarApiReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.MapGet("/hello", () => "Привет, мир API!");
|
||||||
|
|
||||||
|
app.MapGet("/pokemons", () => Results.Ok(pokemons));
|
||||||
|
|
||||||
|
app.MapGet("/pokemons/{id:int}", (int id) =>
|
||||||
|
{
|
||||||
|
var pokemon = pokemons.FirstOrDefault(p => p.Id == id);
|
||||||
|
return pokemon is null ? Results.NotFound() : Results.Ok(pokemon);
|
||||||
|
});
|
||||||
|
|
||||||
|
// POST /pokemons — создать нового покемона
|
||||||
|
app.MapPost("/pokemons", (PokemonInput input) =>
|
||||||
|
{
|
||||||
|
var errors = Validate(input);
|
||||||
|
if (errors.Count > 0)
|
||||||
|
{
|
||||||
|
return Results.BadRequest(new {errors});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var newId = pokemons.Max(p => p.Id) + 1;
|
||||||
|
var pokemon = new Pokemon(newId, input.Name, input.Type, input.Level);
|
||||||
|
pokemons.Add(pokemon);
|
||||||
|
|
||||||
|
return Results.Created($"/pokemons/{newId}", pokemon);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// PUT /pokemons/{id} — заменить покемона по id
|
||||||
|
app.MapPut("/pokemons/{id}", (int id, PokemonInput input) =>
|
||||||
|
{
|
||||||
|
var existing = pokemons.FirstOrDefault(p => p.Id == id);
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
return Results.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
var errors = Validate(input);
|
||||||
|
if (errors.Count > 0)
|
||||||
|
{
|
||||||
|
return Results.BadRequest(new { errors });
|
||||||
|
}
|
||||||
|
|
||||||
|
var updated = new Pokemon(id, input.Name, input.Type, input.Level);
|
||||||
|
pokemons[pokemons.IndexOf(existing)] = updated;
|
||||||
|
|
||||||
|
return Results.Ok(updated);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// DELETE /pokemons/{id} — удалить покемона по id
|
||||||
|
app.MapDelete("/pokemons/{id}", (int id) =>
|
||||||
|
{
|
||||||
|
var existing = pokemons.FirstOrDefault(p => p.Id == id);
|
||||||
|
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
return Results.NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
pokemons.Remove(existing);
|
||||||
|
|
||||||
|
return Results.NoContent();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
static List<string> Validate(PokemonInput input)
|
||||||
|
{
|
||||||
|
var allowedTypes = new[] { "Fire", "Water", "Grass", "Electric",
|
||||||
|
"Psychic", "Normal", "Flying", "Poison" };
|
||||||
|
var errors = new List<string>();
|
||||||
|
if (string.IsNullOrWhiteSpace(input.Name)) errors.Add("Name должен быть не короче 2 символов");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.Type)) errors.Add($"Type '{input.Type}' не поддерживается");
|
||||||
|
|
||||||
|
if (input.Level <= 1 | input.Level >= 100) errors.Add("Level должен быть в диапазоне 1..100");
|
||||||
|
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Pokemon(int Id, string Name, string Type, int Level);
|
||||||
|
public record PokemonInput(string Name, string Type, int Level);
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "http://localhost:5104",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "https://localhost:7273;http://localhost:5104",
|
||||||
|
"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,39 @@
|
|||||||
|
info:
|
||||||
|
name: delete /pokemons/:id
|
||||||
|
type: http
|
||||||
|
seq: 6
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: DELETE
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
method: DELETE
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
info:
|
||||||
|
name: PokedexApi1
|
||||||
|
type: folder
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
info:
|
||||||
|
name: get /hello
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{baseUrl}}/hello"
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/hello"
|
||||||
|
method: GET
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
headers:
|
||||||
|
- name: Content-Type
|
||||||
|
value: text/plain
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
info:
|
||||||
|
name: get /pokemons/:id
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
method: GET
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
info:
|
||||||
|
name: get /pokemons
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{baseUrl}}/pokemons"
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/pokemons"
|
||||||
|
method: GET
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
info:
|
||||||
|
name: post /pokemons
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: POST
|
||||||
|
url: "{{baseUrl}}/pokemons"
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
data: |-
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "",
|
||||||
|
"level": ""
|
||||||
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/pokemons"
|
||||||
|
method: POST
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
data: |-
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "",
|
||||||
|
"level": ""
|
||||||
|
}
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
info:
|
||||||
|
name: put /pokemons/:id
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
tags:
|
||||||
|
- PokedexApi1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: PUT
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
data: |-
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "",
|
||||||
|
"level": ""
|
||||||
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
forwardAuthorizationHeader: false
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- name: 200 Response
|
||||||
|
description: OK
|
||||||
|
request:
|
||||||
|
url: "{{baseUrl}}/pokemons/:id"
|
||||||
|
method: PUT
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: ""
|
||||||
|
type: path
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
data: |-
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "",
|
||||||
|
"level": ""
|
||||||
|
}
|
||||||
|
response:
|
||||||
|
status: 200
|
||||||
|
statusText: OK
|
||||||
|
body:
|
||||||
|
type: text
|
||||||
|
data: ""
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
name: local
|
||||||
|
variables:
|
||||||
|
- name: baseUrl
|
||||||
|
value: http://localhost:5104
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
opencollection: 1.0.0
|
||||||
|
|
||||||
|
info:
|
||||||
|
name: PokedexApi1 | v1
|
||||||
|
bundled: false
|
||||||
|
extensions:
|
||||||
|
bruno:
|
||||||
|
ignore:
|
||||||
|
- node_modules
|
||||||
|
- .git
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# Лабораторная работа №1
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа № 1:** [ Введение в язык C#. Переменные, базовые типы данных и консольный ввод/вывод информации]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson1
|
||||||
|
{
|
||||||
|
class lesson1
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("1 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
// string pokemonName = "Чармандер" ;
|
||||||
|
// string elementType ="Огонь" ;
|
||||||
|
// int level = 1 ;
|
||||||
|
// int hp = 95;
|
||||||
|
// Console.WriteLine("=== БАЗА ДАННЫХ ПОКЕМОНОВ ===");
|
||||||
|
// Console.WriteLine($"Покемон: {pokemonName}");
|
||||||
|
// Console.WriteLine($"Стихия: {elementType}");
|
||||||
|
// Console.WriteLine($"Уровень: {level} | HP: {hp}");
|
||||||
|
|
||||||
|
Console.WriteLine("1 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
Console.Write($"Введите имя тренера: ");
|
||||||
|
string trainerName = Console.ReadLine();
|
||||||
|
Console.Write($"Введите имя покемона: ");
|
||||||
|
string pokemonName = Console.ReadLine();
|
||||||
|
Console.Write($"Введите стихию: ");
|
||||||
|
string elementType = Console.ReadLine();
|
||||||
|
Console.Write($"Введите регион: ");
|
||||||
|
string regionName = Console.ReadLine();
|
||||||
|
Console.WriteLine("****************************************");
|
||||||
|
Console.WriteLine("ПАСПОРТ ПОКЕМОНА");
|
||||||
|
Console.WriteLine($"Тренер: {trainerName} (Регион: {regionName})");
|
||||||
|
Console.WriteLine($"Покемон: {pokemonName} [Стихия: {elementType}]");
|
||||||
|
Console.WriteLine("****************************************");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ответ:
|
||||||
|
|
||||||
|
1 БЛОК 1 ЗАДАНИЕ
|
||||||
|
=== БАЗА ДАННЫХ ПОКЕМОНОВ ===
|
||||||
|
Покемон: Чармандер
|
||||||
|
Стихия: Огонь
|
||||||
|
Уровень: 1 | HP: 95
|
||||||
|
|
||||||
|
1 БЛОК 2 ЗАДАНИЕ
|
||||||
|
Введите имя тренера: Эш
|
||||||
|
Введите имя покемона: Булбазавр
|
||||||
|
Введите стихию: Трава
|
||||||
|
Введите регион: Канто
|
||||||
|
****************************************
|
||||||
|
ПАСПОРТ ПОКЕМОНА
|
||||||
|
Тренер: Эш (Регион: Канто)
|
||||||
|
Покемон: Булбазавр [Стихия: Трава]
|
||||||
|
****************************************
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
|
|
||||||
|
|
||||||
@@ -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", "{EBC5DA53-6234-4418-BE96-42D2151BA6EE}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{EBC5DA53-6234-4418-BE96-42D2151BA6EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EBC5DA53-6234-4418-BE96-42D2151BA6EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EBC5DA53-6234-4418-BE96-42D2151BA6EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EBC5DA53-6234-4418-BE96-42D2151BA6EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson1
|
||||||
|
{
|
||||||
|
class lesson1
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("1 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
// string pokemonName = "Чармандер" ;
|
||||||
|
// string elementType ="Огонь" ;
|
||||||
|
// int level = 1 ;
|
||||||
|
// int hp = 95;
|
||||||
|
// Console.WriteLine("=== БАЗА ДАННЫХ ПОКЕМОНОВ ===");
|
||||||
|
// Console.WriteLine($"Покемон: {pokemonName}");
|
||||||
|
// Console.WriteLine($"Стихия: {elementType}");
|
||||||
|
// Console.WriteLine($"Уровень: {level} | HP: {hp}");
|
||||||
|
|
||||||
|
Console.WriteLine("1 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
Console.Write($"Введите имя тренера: ");
|
||||||
|
string trainerName = Console.ReadLine();
|
||||||
|
Console.Write($"Введите имя покемона: ");
|
||||||
|
string pokemonName = Console.ReadLine();
|
||||||
|
Console.Write($"Введите стихию: ");
|
||||||
|
string elementType = Console.ReadLine();
|
||||||
|
Console.Write($"Введите регион: ");
|
||||||
|
string regionName = Console.ReadLine();
|
||||||
|
Console.WriteLine("****************************************");
|
||||||
|
Console.WriteLine("ПАСПОРТ ПОКЕМОНА");
|
||||||
|
Console.WriteLine($"Тренер: {trainerName} (Регион: {regionName})");
|
||||||
|
Console.WriteLine($"Покемон: {pokemonName} [Стихия: {elementType}]");
|
||||||
|
Console.WriteLine("****************************************");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab-02", "Lab-02\Lab-02.csproj", "{5982AD7F-CDDC-4556-B8C9-4A1BA7EBE15B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5982AD7F-CDDC-4556-B8C9-4A1BA7EBE15B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5982AD7F-CDDC-4556-B8C9-4A1BA7EBE15B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5982AD7F-CDDC-4556-B8C9-4A1BA7EBE15B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5982AD7F-CDDC-4556-B8C9-4A1BA7EBE15B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<RootNamespace>Lab_02</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
namespace Lesson2
|
||||||
|
{
|
||||||
|
class Lesson2Tasks
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("=== Прокачка покемона ===");
|
||||||
|
Console.WriteLine($"Введите базовое значение атаки: ");
|
||||||
|
int baseAttack = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Базовое значение атаки:{baseAttack} ");
|
||||||
|
Console.WriteLine($"Введите количество полученных уровней:");
|
||||||
|
int levelGained = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество полученных уровней:{levelGained}");
|
||||||
|
int finalDamage = baseAttack + (levelGained * 5);
|
||||||
|
Console.WriteLine($"Итоговое значение аттаки: {finalDamage}");
|
||||||
|
|
||||||
|
Console.WriteLine("1 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
int coachBalance = 1500;
|
||||||
|
Console.WriteLine($"Текущий баланс тренера: {coachBalance} ");
|
||||||
|
int potionPrice = 200;
|
||||||
|
Console.WriteLine($"Стоимость одного зелья: {potionPrice}");
|
||||||
|
Console.WriteLine($"Введите Количество приобретаемых зелий:");
|
||||||
|
int potionCount = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество приобретаемых зелий: {potionCount}");
|
||||||
|
int priceTotal = potionCount * potionPrice;
|
||||||
|
int remainBalance = coachBalance - priceTotal;
|
||||||
|
Console.WriteLine ($"Успешная покупка! Остаток средств: {remainBalance}");
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Введите текущее количество HP");
|
||||||
|
int HP = int.Parse(Console.ReadLine());
|
||||||
|
if (HP <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
|
||||||
|
}
|
||||||
|
else if (HP > 0 & HP < 21)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
|
||||||
|
}
|
||||||
|
else if (HP >= 21 & HP <= 50)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон ранен, будьте осторожны.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон полон сил и готов к бою!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Выберите действие тренера:");
|
||||||
|
Console.WriteLine("1 — Атака");
|
||||||
|
Console.WriteLine("2 — Инвентарь");
|
||||||
|
Console.WriteLine("3 — Сменить покемона");
|
||||||
|
Console.WriteLine("4 — Побег");
|
||||||
|
int action = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine($"Вы выбрали: {action}");
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
Console.WriteLine("Покемон наносит быстрый удар!");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Console.WriteLine("Вы отозвали покемона и выпустили нового!");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Console.WriteLine("Вы успешно сбежали из боя!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Submodule
+1
Submodule works/CSharp/lab-02/Lesson2 added at 937709b2ae
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
namespace Lesson2
|
||||||
|
{
|
||||||
|
class Lesson2Tasks
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Console.WriteLine("1 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("=== Прокачка покемона ===");
|
||||||
|
Console.WriteLine($"Введите базовое значение атаки: ");
|
||||||
|
int baseAttack = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Базовое значение атаки:{baseAttack} ");
|
||||||
|
Console.WriteLine($"Введите количество полученных уровней:");
|
||||||
|
int levelGained = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество полученных уровней:{levelGained}");
|
||||||
|
int finalDamage = baseAttack + (levelGained * 5);
|
||||||
|
Console.WriteLine($"Итоговое значение аттаки: {finalDamage}");
|
||||||
|
|
||||||
|
Console.WriteLine("1 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
int coachBalance = 1500;
|
||||||
|
Console.WriteLine($"Текущий баланс тренера: {coachBalance} ");
|
||||||
|
int potionPrice = 200;
|
||||||
|
Console.WriteLine($"Стоимость одного зелья: {potionPrice}");
|
||||||
|
int potionCount = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество приобретаемых зелий: {potionCount}");
|
||||||
|
int priceTotal = potionCount * potionPrice;
|
||||||
|
int remainBalance = coachBalance - priceTotal;
|
||||||
|
Console.WriteLine ($"Успешная покупка! Остаток средств: {remainBalance}");
|
||||||
|
*/
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Введите текущее количество HP");
|
||||||
|
int HP = int.Parse(Console.ReadLine());
|
||||||
|
if (HP <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
|
||||||
|
}
|
||||||
|
else if (HP > 0 & HP < 21)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
|
||||||
|
}
|
||||||
|
else if (HP >= 21 & HP <= 50)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон ранен, будьте осторожны.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон полон сил и готов к бою!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Выберите действие тренера:");
|
||||||
|
Console.WriteLine("1 — Атака");
|
||||||
|
Console.WriteLine("2 — Инвентарь");
|
||||||
|
Console.WriteLine("3 — Сменить покемона");
|
||||||
|
Console.WriteLine("4 — Побег");
|
||||||
|
int action = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine($"Вы выбрали: {action}");
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
Console.WriteLine("Покемон наносит быстрый удар!");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Console.WriteLine("Вы отозвали покемона и выпустили нового!");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Console.WriteLine("Вы успешно сбежали из боя!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
# Лабораторная работа №2
|
||||||
|
|
||||||
|
* **Студент:** Пузанова Анна Андреевна
|
||||||
|
* **Лабораторная работа № 2:** [Ввод данных и преобразование типов (int.Parse)]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
// Самая важная часть реализации (методы, структуры, логика)
|
||||||
|
public class Card
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Hp { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
using System;
|
||||||
|
namespace Lesson2
|
||||||
|
{
|
||||||
|
class Lesson2Tasks
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("=== Прокачка покемона ===");
|
||||||
|
Console.WriteLine($"Введите базовое значение атаки: ");
|
||||||
|
int baseAttack = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Базовое значение атаки:{baseAttack} ");
|
||||||
|
Console.WriteLine($"Введите количество полученных уровней:");
|
||||||
|
int levelGained = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество полученных уровней:{levelGained}");
|
||||||
|
int finalDamage = baseAttack + (levelGained * 5);
|
||||||
|
Console.WriteLine($"Итоговое значение аттаки: {finalDamage}");
|
||||||
|
|
||||||
|
Console.WriteLine("1 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
int coachBalance = 1500;
|
||||||
|
Console.WriteLine($"Текущий баланс тренера: {coachBalance} ");
|
||||||
|
int potionPrice = 200;
|
||||||
|
Console.WriteLine($"Стоимость одного зелья: {potionPrice}");
|
||||||
|
Console.WriteLine($"Введите Количество приобретаемых зелий:");
|
||||||
|
int potionCount = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine($"Количество приобретаемых зелий: {potionCount}");
|
||||||
|
int priceTotal = potionCount * potionPrice;
|
||||||
|
int remainBalance = coachBalance - priceTotal;
|
||||||
|
Console.WriteLine ($"Успешная покупка! Остаток средств: {remainBalance}");
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Введите текущее количество HP");
|
||||||
|
int HP = int.Parse(Console.ReadLine());
|
||||||
|
if (HP <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон потерял сознание! Верните его в покебол.");
|
||||||
|
}
|
||||||
|
else if (HP > 0 & HP < 21)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Критическое состояние! Срочно используйте зелье!");
|
||||||
|
}
|
||||||
|
else if (HP >= 21 & HP <= 50)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон ранен, будьте осторожны.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон полон сил и готов к бою!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("2 БЛОК 2 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("Выберите действие тренера:");
|
||||||
|
Console.WriteLine("1 — Атака");
|
||||||
|
Console.WriteLine("2 — Инвентарь");
|
||||||
|
Console.WriteLine("3 — Сменить покемона");
|
||||||
|
Console.WriteLine("4 — Побег");
|
||||||
|
int action = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine($"Вы выбрали: {action}");
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
Console.WriteLine("Покемон наносит быстрый удар!");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Console.WriteLine("Вы открыли сумку и применили Зелье Лечения.");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Console.WriteLine("Вы отозвали покемона и выпустили нового!");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Console.WriteLine("Вы успешно сбежали из боя!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Неизвестная команда! Вы пропустили ход.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
1 БЛОК 1 ЗАДАНИЕ
|
||||||
|
=== Прокачка покемона ===
|
||||||
|
Введите базовое значение атаки:
|
||||||
|
4
|
||||||
|
Базовое значение атаки:4
|
||||||
|
Введите количество полученных уровней:
|
||||||
|
5
|
||||||
|
Количество полученных уровней:5
|
||||||
|
Итоговое значение аттаки: 29
|
||||||
|
1 БЛОК 2 ЗАДАНИЕ
|
||||||
|
Текущий баланс тренера: 1500
|
||||||
|
Стоимость одного зелья: 200
|
||||||
|
Введите Количество приобретаемых зелий:
|
||||||
|
8
|
||||||
|
Количество приобретаемых зелий: 8
|
||||||
|
Успешная покупка! Остаток средств: -100
|
||||||
|
2 БЛОК 1 ЗАДАНИЕ
|
||||||
|
Введите текущее количество HP
|
||||||
|
34
|
||||||
|
Покемон ранен, будьте осторожны.
|
||||||
|
2 БЛОК 2 ЗАДАНИЕ
|
||||||
|
Выберите действие тренера:
|
||||||
|
1 - Атака
|
||||||
|
2 - Инвентарь
|
||||||
|
3 - Сменить покемона
|
||||||
|
4 - Побег
|
||||||
|
5
|
||||||
|
|
||||||
|
Вы выбрали: 5
|
||||||
|
Неизвестная команда! Вы пропустили ход.
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
# Лабораторная работа №3
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа № 3:** [Циклы и управление потоком выполнения. Игровой цикл пошагового боя]
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
|
||||||
|
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 = 50;
|
||||||
|
int pokemon2Hp = 55;
|
||||||
|
int roundNumber = 1;
|
||||||
|
|
||||||
|
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||||
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
|
pokemon2Hp -= pokemon1Attack;
|
||||||
|
if (pokemon2Hp <= 0)
|
||||||
|
{
|
||||||
|
pokemon2Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon2Name} потерял сознание!");
|
||||||
|
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||||
|
Console.WriteLine($"Победитель: {pokemon1Name}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||||
|
pokemon1Hp -= pokemon2Attack;
|
||||||
|
if (pokemon1Hp <= 0 )
|
||||||
|
{
|
||||||
|
pokemon1Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon1Name} потерял сознание!");
|
||||||
|
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||||
|
Console.WriteLine($"Победитель: {pokemon2Name}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
roundNumber++;
|
||||||
|
Console.WriteLine($"Итог раунда: Пикачу HP: {pokemon1Hp} | Булбазавр HP: {pokemon2Hp}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1 ЗАДАНИЕ
|
||||||
|
3..
|
||||||
|
2..
|
||||||
|
1..
|
||||||
|
=== БОЙ НАЧИНАЕТСЯ ===
|
||||||
|
Пикачу (HP: 50 | Атака: 12) VS Булбазавр (HP: 55 | Атака: 10)
|
||||||
|
|
||||||
|
2 ЗАДАНИЕ
|
||||||
|
Готовы начать бой? (1 - Да, 0 - Нет): 5
|
||||||
|
Некорректная команда! Попробуйте снова.
|
||||||
|
Готовы начать бой? (1 - Да, 0 - Нет): 0
|
||||||
|
Вы отменили бой!
|
||||||
|
|
||||||
|
3 ЗАДАНИЕ
|
||||||
|
--- Раунд 1 ---
|
||||||
|
Пикачу наносит 12 урона по Булбазавр!
|
||||||
|
Булбазавр наносит 10 урона по Пикачу!
|
||||||
|
Итог раунда: Пикачу HP: 40 | Булбазавр HP: 43
|
||||||
|
--- Раунд 2 ---
|
||||||
|
Пикачу наносит 12 урона по Булбазавр!
|
||||||
|
Булбазавр наносит 10 урона по Пикачу!
|
||||||
|
Итог раунда: Пикачу HP: 30 | Булбазавр HP: 31
|
||||||
|
--- Раунд 3 ---
|
||||||
|
Пикачу наносит 12 урона по Булбазавр!
|
||||||
|
Булбазавр наносит 10 урона по Пикачу!
|
||||||
|
Итог раунда: Пикачу HP: 20 | Булбазавр HP: 19
|
||||||
|
--- Раунд 4 ---
|
||||||
|
Пикачу наносит 12 урона по Булбазавр!
|
||||||
|
Булбазавр наносит 10 урона по Пикачу!
|
||||||
|
Итог раунда: Пикачу HP: 10 | Булбазавр HP: 7
|
||||||
|
--- Раунд 5 ---
|
||||||
|
Пикачу наносит 12 урона по Булбазавр!
|
||||||
|
Булбазавр потерял сознание!
|
||||||
|
=== БОЙ ОКОНЧЕН ===
|
||||||
|
Победитель: Пикачу
|
||||||
@@ -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,85 @@
|
|||||||
|
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 = 50;
|
||||||
|
int pokemon2Hp = 55;
|
||||||
|
int roundNumber = 1;
|
||||||
|
|
||||||
|
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||||
|
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||||
|
pokemon2Hp -= pokemon1Attack;
|
||||||
|
if (pokemon2Hp <= 0)
|
||||||
|
{
|
||||||
|
pokemon2Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon2Name} потерял сознание!");
|
||||||
|
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||||
|
Console.WriteLine($"Победитель: {pokemon1Name}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||||
|
pokemon1Hp -= pokemon2Attack;
|
||||||
|
if (pokemon1Hp <= 0 )
|
||||||
|
{
|
||||||
|
pokemon1Hp = 0;
|
||||||
|
Console.WriteLine($"{pokemon1Name} потерял сознание!");
|
||||||
|
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
|
||||||
|
Console.WriteLine($"Победитель: {pokemon2Name}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
roundNumber++;
|
||||||
|
Console.WriteLine($"Итог раунда: Пикачу HP: {pokemon1Hp} | Булбазавр HP: {pokemon2Hp}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,98 @@
|
|||||||
|
# Лабораторная работа №4
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа №4:** [Массивы и динамические списки. Цикл foreach и работа с коллекциями данных]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson4
|
||||||
|
{
|
||||||
|
class lesson4
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ===");
|
||||||
|
string[] activeTeam = new string[3];
|
||||||
|
for (int i = 0; i < activeTeam.Length; i++)
|
||||||
|
{
|
||||||
|
Console.Write($"Введите имя покемона №{i + 1}: ");
|
||||||
|
activeTeam[i] = Console.ReadLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine("\n--- Ваша команда на этот бой ---");
|
||||||
|
Console.WriteLine($"1. {activeTeam[0]}");
|
||||||
|
Console.WriteLine($"2. {activeTeam[1]}");
|
||||||
|
Console.WriteLine($"3. {activeTeam[2]}");
|
||||||
|
|
||||||
|
Console.WriteLine("2 ЗАДАНИЕ");
|
||||||
|
|
||||||
|
List<string> backpack = new List<string>();
|
||||||
|
backpack.Add("Зелье HP");
|
||||||
|
backpack.Add("Покебол");
|
||||||
|
backpack.Add("Антидот");
|
||||||
|
int count = backpack.Count;
|
||||||
|
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {count}");
|
||||||
|
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
|
||||||
|
backpack.Remove("Покебол");
|
||||||
|
int count1 = backpack.Count;
|
||||||
|
Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {count1}");
|
||||||
|
|
||||||
|
Console.WriteLine("3 ЗАДАНИЕ");
|
||||||
|
|
||||||
|
Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ===");
|
||||||
|
List<string> backpack = new List<string>();
|
||||||
|
backpack.Add("Зелье HP");
|
||||||
|
backpack.Add("Покебол");
|
||||||
|
backpack.Add("Антидот");
|
||||||
|
int count = backpack.Count;
|
||||||
|
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {count}");
|
||||||
|
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
|
||||||
|
backpack.Remove("Покебол");
|
||||||
|
int count1 = backpack.Count;
|
||||||
|
Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {count1}");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("--- Содержимое вашей сумки ---");
|
||||||
|
foreach (string item in backpack)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[Предмет] -> {item}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("=============================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
1 ЗАДАНИЕ
|
||||||
|
=== РЕГИСТРАЦИЯ КОМАНДЫ ===
|
||||||
|
Введите имя покемона №1: Булбазавр
|
||||||
|
Введите имя покемона №2: Пикачу
|
||||||
|
Введите имя покемона №3: Чармандер
|
||||||
|
|
||||||
|
--- Ваша команда на этот бой ---
|
||||||
|
1. Булбазавр
|
||||||
|
2. Пикачу
|
||||||
|
3. Чармандер
|
||||||
|
|
||||||
|
2 ЗАДАНИЕ
|
||||||
|
Вы положили вещи в сумку. Предметов в инвентаре: 3
|
||||||
|
Вы использовали один Покебол для поимки дикого покемона!
|
||||||
|
Обновленный инвентарь. Осталось предметов: 2
|
||||||
|
|
||||||
|
3 ЗАДАНИЕ
|
||||||
|
=== ИНВЕНТАРЬ ТРЕНЕРА ===
|
||||||
|
Вы положили вещи в сумку. Предметов в инвентаре: 3
|
||||||
|
Вы использовали один Покебол для поимки дикого покемона!
|
||||||
|
Обновленный инвентарь. Осталось предметов: 2
|
||||||
|
|
||||||
|
--- Содержимое вашей сумки ---
|
||||||
|
[Предмет] -> Зелье HP
|
||||||
|
[Предмет] -> Антидот
|
||||||
|
=============================
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-04", "lab-04\lab-04.csproj", "{ADD29857-08D8-4E9D-90B6-5F47FC00FD5B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{ADD29857-08D8-4E9D-90B6-5F47FC00FD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ADD29857-08D8-4E9D-90B6-5F47FC00FD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ADD29857-08D8-4E9D-90B6-5F47FC00FD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ADD29857-08D8-4E9D-90B6-5F47FC00FD5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson4
|
||||||
|
{
|
||||||
|
class lesson4
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1 ЗАДАНИЕ");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ===");
|
||||||
|
string[] activeTeam = new string[3];
|
||||||
|
for (int i = 0; i < activeTeam.Length; i++)
|
||||||
|
{
|
||||||
|
Console.Write($"Введите имя покемона №{i + 1}: ");
|
||||||
|
activeTeam[i] = Console.ReadLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine("\n--- Ваша команда на этот бой ---");
|
||||||
|
Console.WriteLine($"1. {activeTeam[0]}");
|
||||||
|
Console.WriteLine($"2. {activeTeam[1]}");
|
||||||
|
Console.WriteLine($"3. {activeTeam[2]}");
|
||||||
|
|
||||||
|
Console.WriteLine("2 ЗАДАНИЕ");
|
||||||
|
|
||||||
|
List<string> backpack = new List<string>();
|
||||||
|
backpack.Add("Зелье HP");
|
||||||
|
backpack.Add("Покебол");
|
||||||
|
backpack.Add("Антидот");
|
||||||
|
int count = backpack.Count;
|
||||||
|
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {count}");
|
||||||
|
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
|
||||||
|
backpack.Remove("Покебол");
|
||||||
|
int count1 = backpack.Count;
|
||||||
|
Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {count1}");
|
||||||
|
|
||||||
|
Console.WriteLine("3 ЗАДАНИЕ");
|
||||||
|
|
||||||
|
Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ===");
|
||||||
|
List<string> backpack = new List<string>();
|
||||||
|
backpack.Add("Зелье HP");
|
||||||
|
backpack.Add("Покебол");
|
||||||
|
backpack.Add("Антидот");
|
||||||
|
int count = backpack.Count;
|
||||||
|
Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {count}");
|
||||||
|
Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!");
|
||||||
|
backpack.Remove("Покебол");
|
||||||
|
int count1 = backpack.Count;
|
||||||
|
Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {count1}");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("--- Содержимое вашей сумки ---");
|
||||||
|
foreach (string item in backpack)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[Предмет] -> {item}");
|
||||||
|
}
|
||||||
|
Console.WriteLine("=============================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<RootNamespace>lab_04</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lab5
|
||||||
|
{
|
||||||
|
class lab5
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
|
||||||
|
{
|
||||||
|
Console.WriteLine("Задание 1. Лечение в Покецентре (Использование ref)");
|
||||||
|
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
|
||||||
|
int pokemonHP = 20;
|
||||||
|
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP");
|
||||||
|
|
||||||
|
static void HealPokemon(ref int myPokemonHP)
|
||||||
|
{
|
||||||
|
myPokemonHP += 80;
|
||||||
|
Console.WriteLine($"[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
|
||||||
|
}
|
||||||
|
|
||||||
|
HealPokemon(ref pokemonHP);
|
||||||
|
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP");
|
||||||
|
|
||||||
|
Console.WriteLine("\nЗадание 2. Поиск дикого покемона в высокой траве (Использование out)");
|
||||||
|
Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
|
||||||
|
Console.WriteLine("Вы зашли в высокую траву...");
|
||||||
|
|
||||||
|
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
|
||||||
|
{
|
||||||
|
foundPokemon = "Пикачу";
|
||||||
|
Random rnd = new Random();
|
||||||
|
pokemonLevel = rnd.Next(1, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchBushes(out string Pokemon, out int Level);
|
||||||
|
|
||||||
|
Console.WriteLine($"Шорох! Из кустов появляется дикий {Pokemon} (Уровень: {Level})!");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
|
||||||
|
RegisterTournament(1.5, "Бульбазавр", "Чармандер");
|
||||||
|
Console.WriteLine("-----------------------------");
|
||||||
|
RegisterTournament(1.5, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
|
||||||
|
Console.WriteLine("=============================");
|
||||||
|
|
||||||
|
static void RegisterTournament(in double difficulty, params string[] participants)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
|
||||||
|
Console.WriteLine($"Список участников:");
|
||||||
|
foreach (string pokemon in participants)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"* {pokemon}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
# Лабораторная работа №5
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа №5:** [Функции и методы в C#. Возвращаемые значения и модификаторы параметров (ref, out, in, params)]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lab5
|
||||||
|
{
|
||||||
|
class lab5
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
|
||||||
|
{
|
||||||
|
Console.WriteLine("Задание 1. Лечение в Покецентре (Использование ref)");
|
||||||
|
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
|
||||||
|
int pokemonHP = 20;
|
||||||
|
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP");
|
||||||
|
|
||||||
|
static void HealPokemon(ref int myPokemonHP)
|
||||||
|
{
|
||||||
|
myPokemonHP += 80;
|
||||||
|
Console.WriteLine($"[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
|
||||||
|
}
|
||||||
|
|
||||||
|
HealPokemon(ref pokemonHP);
|
||||||
|
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP");
|
||||||
|
|
||||||
|
Console.WriteLine("\nЗадание 2. Поиск дикого покемона в высокой траве (Использование out)");
|
||||||
|
Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
|
||||||
|
Console.WriteLine("Вы зашли в высокую траву...");
|
||||||
|
|
||||||
|
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
|
||||||
|
{
|
||||||
|
|
||||||
|
foundPokemon = "Пикачу";
|
||||||
|
Random rnd = new Random();
|
||||||
|
pokemonLevel = rnd.Next(1, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchBushes(out string Pokemon, out int Level);
|
||||||
|
|
||||||
|
Console.WriteLine($"Шорох! Из кустов появляется дикий {Pokemon} (Уровень: {Level})!");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
|
||||||
|
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
|
||||||
|
RegisterTournament(1.5, "Бульбазавр", "Чармандер");
|
||||||
|
Console.WriteLine("-----------------------------");
|
||||||
|
RegisterTournament(1.5, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
|
||||||
|
Console.WriteLine("=============================");
|
||||||
|
|
||||||
|
static void RegisterTournament(in double difficulty, params string[] participants)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
|
||||||
|
Console.WriteLine($"Список участников:");
|
||||||
|
|
||||||
|
|
||||||
|
foreach (string pokemon in participants)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"* {pokemon}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
ЗЗадание 1. Лечение в Покецентре (Использование ref)
|
||||||
|
=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===
|
||||||
|
Здоровье до лечения: 20 HP
|
||||||
|
[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.
|
||||||
|
Здоровье после лечения: 100 HP
|
||||||
|
|
||||||
|
Задание 2. Поиск дикого покемона в высокой траве (Использование out)
|
||||||
|
=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===
|
||||||
|
Вы зашли в высокую траву...
|
||||||
|
Шорох! Из кустов появляется дикий Пикачу (Уровень: 4)!
|
||||||
|
=== РЕГИСТРАЦИЯ НА ТУРНИР ===
|
||||||
|
=== РЕГИСТРАЦИЯ НА ТУРНИР ===
|
||||||
|
Коэффициент стадиона: 1,5
|
||||||
|
Список участников:
|
||||||
|
* Бульбазавр
|
||||||
|
* Чармандер
|
||||||
|
-----------------------------
|
||||||
|
Коэффициент стадиона: 1,5
|
||||||
|
Список участников:
|
||||||
|
* Сквиртл
|
||||||
|
* Пикачу
|
||||||
|
* Псайдак
|
||||||
|
* Мяут
|
||||||
|
=============================
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<RootNamespace>lab_05</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-05", "lab-05.csproj", "{993468BA-62CE-4D90-8D33-0F4853957FC1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{993468BA-62CE-4D90-8D33-0F4853957FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{993468BA-62CE-4D90-8D33-0F4853957FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{993468BA-62CE-4D90-8D33-0F4853957FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{993468BA-62CE-4D90-8D33-0F4853957FC1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Pokemon pika = new Pokemon("Пикачу", 5, 100);
|
||||||
|
Pokemon skvirtl = new Pokemon("Сквиртл", 5, 90);
|
||||||
|
Pokemon bulbazavr = new Pokemon("Бульбазавр", 9, 80);
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 1 ===");
|
||||||
|
Console.WriteLine("=== ПОКЕДЕКС ===");
|
||||||
|
pika.ShowInfo();
|
||||||
|
skvirtl.ShowInfo();
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 2 ===");
|
||||||
|
Console.WriteLine("=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===");
|
||||||
|
;
|
||||||
|
Console.WriteLine($"Попытка установить HP = {pika.HP = -50}...");
|
||||||
|
Console.WriteLine($"Текущее HP: {pika.HP} (защита сработала)");
|
||||||
|
pika.Heal();
|
||||||
|
pika.TakeDamage(30);
|
||||||
|
Console.WriteLine($"Покемон получил {30} урона. HP: {pika.HP}");
|
||||||
|
pika.Heal();
|
||||||
|
Console.WriteLine($"Покемон вылечился. HP: {pika.HP}");
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 3 ===");
|
||||||
|
Console.WriteLine("=== ПОКЕДЕКС: СТАТИСТИКА ===");
|
||||||
|
Console.WriteLine($"Создано покемонов: {Pokemon.Count}");
|
||||||
|
Console.WriteLine("=== БИТВА ===");
|
||||||
|
pika.Battle(skvirtl);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pokemon
|
||||||
|
{
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
private int level;
|
||||||
|
private int hp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
name = "Безымянный";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Level
|
||||||
|
{
|
||||||
|
get { return level; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1) level = 1;
|
||||||
|
else if (value > 100) level = 100;
|
||||||
|
else level = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HP
|
||||||
|
{
|
||||||
|
get { return hp; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0) hp = 0;
|
||||||
|
else if (value > 100) hp = 100;
|
||||||
|
else hp = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pokemon(string name, int level, int hp)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.hp = hp;
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Имя: {name}, Уровень: {level}, HP: {hp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TakeDamage(int damage)
|
||||||
|
{
|
||||||
|
if (HP > 0)
|
||||||
|
HP -= damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Heal()
|
||||||
|
{
|
||||||
|
HP = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Count { get; private set; } = 0;
|
||||||
|
Pokemon winner;
|
||||||
|
Pokemon loser;
|
||||||
|
|
||||||
|
public void Battle(Pokemon enemy)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{this.Name} (Ур. {this.Level}), HP {this.HP} против {enemy.Name} (Ур. {enemy.Level}), HP {enemy.HP}");
|
||||||
|
if (this.Level > enemy.Level)
|
||||||
|
{
|
||||||
|
winner = this;
|
||||||
|
loser = enemy;
|
||||||
|
Console.WriteLine($"{winner.Name} побеждает! {loser.Name} теряет {winner.Level} HP.");
|
||||||
|
}
|
||||||
|
else if (this.Level < enemy.Level)
|
||||||
|
{
|
||||||
|
winner = enemy;
|
||||||
|
loser = this;
|
||||||
|
Console.WriteLine($"{winner.Name} побеждает! {loser.Name} теряет {winner.Level} HP.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Силы равны! Ничья.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int damage = winner.Level;
|
||||||
|
loser.TakeDamage(damage);
|
||||||
|
|
||||||
|
Console.WriteLine($"Победитель: {winner.Name}, Осталось HP: {winner.HP}");
|
||||||
|
Console.WriteLine($"Проигравший ({loser.Name}) Осталось HP: {loser.HP}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
# Лабораторная работа №6
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа №6:** [Тема: Классы и объекты в C#. Инкапсуляция, конструкторы, свойства и статические члены]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Pokemon pika = new Pokemon("Пикачу", 5, 100);
|
||||||
|
Pokemon skvirtl = new Pokemon("Сквиртл", 5, 90);
|
||||||
|
Pokemon bulbazavr = new Pokemon("Бульбазавр", 9, 80);
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 1 ===");
|
||||||
|
Console.WriteLine("=== ПОКЕДЕКС ===");
|
||||||
|
pika.ShowInfo();
|
||||||
|
skvirtl.ShowInfo();
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 2 ===");
|
||||||
|
Console.WriteLine("=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===");
|
||||||
|
;
|
||||||
|
Console.WriteLine($"Попытка установить HP = {pika.HP = -50}...");
|
||||||
|
Console.WriteLine($"Текущее HP: {pika.HP} (защита сработала)");
|
||||||
|
pika.Heal();
|
||||||
|
pika.TakeDamage(30);
|
||||||
|
Console.WriteLine($"Покемон получил {30} урона. HP: {pika.HP}");
|
||||||
|
pika.Heal();
|
||||||
|
Console.WriteLine($"Покемон вылечился. HP: {pika.HP}");
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 3 ===");
|
||||||
|
Console.WriteLine("=== ПОКЕДЕКС: СТАТИСТИКА ===");
|
||||||
|
Console.WriteLine($"Создано покемонов: {Pokemon.Count}");
|
||||||
|
Console.WriteLine("=== БИТВА ===");
|
||||||
|
pika.Battle(skvirtl);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pokemon
|
||||||
|
{
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
private int level;
|
||||||
|
private int hp;
|
||||||
|
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
name = "Безымянный";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Level
|
||||||
|
{
|
||||||
|
get { return level; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1) level = 1;
|
||||||
|
else if (value > 100) level = 100;
|
||||||
|
else level = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HP
|
||||||
|
{
|
||||||
|
get { return hp; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0) hp = 0;
|
||||||
|
else if (value > 100) hp = 100;
|
||||||
|
else hp = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pokemon(string name, int level, int hp)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.hp = hp;
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Имя: {name}, Уровень: {level}, HP: {hp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TakeDamage(int damage)
|
||||||
|
{
|
||||||
|
if (HP > 0)
|
||||||
|
HP -= damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Heal()
|
||||||
|
{
|
||||||
|
HP = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Count { get; private set; } = 0;
|
||||||
|
Pokemon winner;
|
||||||
|
Pokemon loser;
|
||||||
|
|
||||||
|
public void Battle(Pokemon enemy)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{this.Name} (Ур. {this.Level}), HP {this.HP} против {enemy.Name} (Ур. {enemy.Level}), HP {enemy.HP}");
|
||||||
|
if (this.Level > enemy.Level)
|
||||||
|
{
|
||||||
|
winner = this;
|
||||||
|
loser = enemy;
|
||||||
|
Console.WriteLine($"{winner.Name} побеждает! {loser.Name} теряет {winner.Level} HP.");
|
||||||
|
}
|
||||||
|
else if (this.Level < enemy.Level)
|
||||||
|
{
|
||||||
|
winner = enemy;
|
||||||
|
loser = this;
|
||||||
|
Console.WriteLine($"{winner.Name} побеждает! {loser.Name} теряет {winner.Level} HP.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Силы равны! Ничья.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int damage = winner.Level;
|
||||||
|
loser.TakeDamage(damage);
|
||||||
|
|
||||||
|
Console.WriteLine($"Победитель: {winner.Name}, Осталось HP: {winner.HP}");
|
||||||
|
Console.WriteLine($"Проигравший ({loser.Name}) Осталось HP: {loser.HP}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
=== ЗАДАНИЕ 1 ===
|
||||||
|
=== ПОКЕДЕКС ===
|
||||||
|
Имя: Пикачу, Уровень: 5, HP: 100
|
||||||
|
Имя: Сквиртл, Уровень: 5, HP: 90
|
||||||
|
=== ЗАДАНИЕ 2 ===
|
||||||
|
=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===
|
||||||
|
Попытка установить HP = -50...
|
||||||
|
Текущее HP: 0 (защита сработала)
|
||||||
|
Покемон получил 30 урона. HP: 70
|
||||||
|
Покемон вылечился. HP: 100
|
||||||
|
=== ЗАДАНИЕ 3 ===
|
||||||
|
=== ПОКЕДЕКС: СТАТИСТИКА ===
|
||||||
|
Создано покемонов: 3
|
||||||
|
=== БИТВА ===
|
||||||
|
Пикачу (Ур. 5), HP 100 против Сквиртл (Ур. 5), HP 90
|
||||||
|
Силы равны! Ничья.
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<RootNamespace>lab_06</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-06", "lab-06.csproj", "{E31A458F-ABCE-4E66-92B8-C39ECB503F82}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E31A458F-ABCE-4E66-92B8-C39ECB503F82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E31A458F-ABCE-4E66-92B8-C39ECB503F82}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E31A458F-ABCE-4E66-92B8-C39ECB503F82}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E31A458F-ABCE-4E66-92B8-C39ECB503F82}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"Version": 1,
|
||||||
|
"WorkspaceRootPath": "Z:\\prog-puzanova\\works\\CSharp\\lab-07\\",
|
||||||
|
"Documents": [],
|
||||||
|
"DocumentGroupContainers": [
|
||||||
|
{
|
||||||
|
"Orientation": 0,
|
||||||
|
"VerticalTabListWidth": 256,
|
||||||
|
"DocumentGroups": [
|
||||||
|
{
|
||||||
|
"DockedWidth": 200,
|
||||||
|
"SelectedChildIndex": -1,
|
||||||
|
"Children": [
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:0:0:{e1b7d1f8-9b3c-49b1-8f4f-bfc63a88835d}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:0:0:{b1e99781-ab81-11d0-b683-00aa00a3ee26}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:0:0:{eefa5220-e298-11d0-8f78-00a0c9110057}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:129:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$type": "Bookmark",
|
||||||
|
"Name": "ST:133:0:{1fc202d4-d401-403c-9834-5b218574bb67}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,466 @@
|
|||||||
|
//ЗАДАНИЕ 11111111111111111111111
|
||||||
|
|
||||||
|
// class Program
|
||||||
|
// {
|
||||||
|
// static void Main()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("=== ЗАДАНИЕ 1 ===");
|
||||||
|
// Console.WriteLine("=== ПОКЕДЕКС: АТАКИ ===");
|
||||||
|
// Pokemon pika = new Pikachu("Пикачу", 5);
|
||||||
|
// pika.ShowInfo();
|
||||||
|
// Pokemon squirtle = new Squirtle("Сквиртл", 7);
|
||||||
|
// squirtle.ShowInfo();
|
||||||
|
// Pokemon charmander = new Charmander("Бульбазавр", 6);
|
||||||
|
// charmander.ShowInfo();
|
||||||
|
//
|
||||||
|
// Console.WriteLine("=== ЗАДАНИЕ 2 ===");
|
||||||
|
// Console.WriteLine("=== ТУРНИР: ВСЕ ПРОТИВ ВСЕХ ===");
|
||||||
|
// pika.ShowInfo();
|
||||||
|
// squirtle.ShowInfo();
|
||||||
|
// charmander.ShowInfo();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public class Pokemon
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// private string name;
|
||||||
|
// private int level;
|
||||||
|
//
|
||||||
|
// public string Name
|
||||||
|
// {
|
||||||
|
// get { return name; }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// if (string.IsNullOrWhiteSpace(value))
|
||||||
|
// {
|
||||||
|
// name = "Безымянный";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// name = value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public int Level
|
||||||
|
// {
|
||||||
|
// get { return level; }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// if (value < 1) level = 1;
|
||||||
|
// else if (value > 100) level = 100;
|
||||||
|
// else level = value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public Pokemon(string name, int level)
|
||||||
|
// {
|
||||||
|
// Name = name;
|
||||||
|
// Level = level;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public virtual void Attack()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"Покемон{Name} атакует.");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public virtual void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"{name} (Ур.{level})");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public class Pikachu : Pokemon
|
||||||
|
// {
|
||||||
|
// public Pikachu(string name, int level) : base(name, level) { }
|
||||||
|
//
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Пика-пика! Удар током!");
|
||||||
|
// }
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Пикачу (Ур. " + Level + "): Пика-пика! Удар током!");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// public class Squirtle : Pokemon // наследник2
|
||||||
|
// {
|
||||||
|
// public Squirtle (string name, int level) : base(name, level)
|
||||||
|
// {}
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Сквирт-сквирт! Водяной пистолет!");
|
||||||
|
// }
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Сквиртл (Ур. " + Level + "): Сквирт-сквиртл! Водяной пистолет!");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public class Charmander : Pokemon // наследник3
|
||||||
|
// {
|
||||||
|
// public Charmander(string name, int level) : base(name, level)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Чар-чар! Огненный хвост!");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Чармандер (Ур. " + Level + "): Чар-чар! Огненный хвост!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//ЗАДАНИЕ 222222222222222222222
|
||||||
|
// class Program
|
||||||
|
// {
|
||||||
|
// static void Main()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("=== ЗАДАНИЕ 2 ===");
|
||||||
|
// Console.WriteLine("=== ТУРНИР: ВСЕ ПРОТИВ ВСЕХ ===");
|
||||||
|
//
|
||||||
|
// // Эту строку нельзя раскомментировать!
|
||||||
|
// // Pokemon p = new Pokemon("Тест", 1);
|
||||||
|
// // Ошибка: нельзя создать объект абстрактного класса.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Pokemon[] pokemons = new Pokemon[4];
|
||||||
|
// pokemons[0] = new Pikachu("Пикачу", 5);
|
||||||
|
// pokemons[1] = new Squirtle("Сквиртл", 7);
|
||||||
|
// pokemons[2] = new Charmander("Чармандер", 6);
|
||||||
|
// pokemons[3] = new Bulbasaur("Бульбазавр", 4);
|
||||||
|
//
|
||||||
|
// Console.WriteLine($"Всего покемонов: {pokemons.Length}");
|
||||||
|
// Console.WriteLine();
|
||||||
|
//
|
||||||
|
// Console.WriteLine("--- Раунд 1 ---");
|
||||||
|
//
|
||||||
|
// foreach (Pokemon pokemon in pokemons)
|
||||||
|
// {
|
||||||
|
// pokemon.ShowInfo();
|
||||||
|
// pokemon.Attack();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Console.WriteLine($"\nВсего атак проведено: {Pokemon.TotalAttacks}");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// abstract class Pokemon
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// private string name;
|
||||||
|
// private int level;
|
||||||
|
// public static int TotalAttacks = 0;
|
||||||
|
// public string Name
|
||||||
|
// {
|
||||||
|
// get { return name; }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// if (string.IsNullOrWhiteSpace(value))
|
||||||
|
// {
|
||||||
|
// name = "Безымянный";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// name = value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public int Level
|
||||||
|
// {
|
||||||
|
// get { return level; }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// if (value < 1) level = 1;
|
||||||
|
// else if (value > 100) level = 100;
|
||||||
|
// else level = value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public Pokemon(string name, int level)
|
||||||
|
// {
|
||||||
|
// Name = name;
|
||||||
|
// Level = level;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public abstract void Attack();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public virtual void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"{name} (Ур.{level})");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// class Pikachu : Pokemon
|
||||||
|
// {
|
||||||
|
// public Pikachu(string name, int level) : base(name, level) { }
|
||||||
|
//
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// TotalAttacks++;
|
||||||
|
// Console.WriteLine("Пика-пика! Удар током!");
|
||||||
|
// }
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Пикачу (Ур. " + Level + "): Пика-пика! Удар током!");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// class Squirtle : Pokemon // наследник2
|
||||||
|
// {
|
||||||
|
// public Squirtle (string name, int level) : base(name, level)
|
||||||
|
// {}
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// TotalAttacks++;
|
||||||
|
// Console.WriteLine("Сквирт-сквирт! Водяной пистолет!");
|
||||||
|
// }
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Сквиртл (Ур. " + Level + "): Сквирт-сквиртл! Водяной пистолет!");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// class Charmander : Pokemon // наследник3
|
||||||
|
// {
|
||||||
|
// public Charmander(string name, int level) : base(name, level)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// TotalAttacks++;
|
||||||
|
// Console.WriteLine("Чар-чар! Огненный хвост!");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Чармандер (Ур. " + Level + "): Чар-чар! Огненный хвост!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// class Bulbasaur : Pokemon // наследник3
|
||||||
|
// {
|
||||||
|
// public Bulbasaur (string name, int level) : base(name, level)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void Attack()
|
||||||
|
// {
|
||||||
|
// TotalAttacks++;
|
||||||
|
// Console.WriteLine("Бульба! Листовой удар!");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public override void ShowInfo()
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Бульбазавр (Ур. " + Level + "): Бульба! Листовой удар!");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//ЗАДАНИЕ 333333333333333333333333333333333
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Console.WriteLine("=== ЗАДАНИЕ 3 ===");
|
||||||
|
Console.WriteLine("=== СПОСОБНОСТИ ПОКЕМОНОВ ===");
|
||||||
|
Pokemon[] pokemons = new Pokemon[3];
|
||||||
|
pokemons[0] = new Magikarp("Магикарп", 5);
|
||||||
|
pokemons[1] = new Pidgeotto("Пиджеотто", 7);
|
||||||
|
pokemons[2] = new Charmander("Чармандер", 6);
|
||||||
|
|
||||||
|
int canEvolve = 0;
|
||||||
|
int canFly = 0;
|
||||||
|
foreach (Pokemon p in pokemons)
|
||||||
|
{
|
||||||
|
p.ShowInfo();
|
||||||
|
if (p is IEvolvable) canEvolve++;
|
||||||
|
if (p is IFlyable) canFly++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Pokemon p in pokemons)
|
||||||
|
{
|
||||||
|
if (p is IEvolvable evolvable)
|
||||||
|
{
|
||||||
|
evolvable.Evolve();
|
||||||
|
}
|
||||||
|
if (p is IFlyable flyable)
|
||||||
|
{
|
||||||
|
flyable.Fly();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p is Magikarp)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Магикарп ничего не умеет, кроме Splash.");
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Итого:");
|
||||||
|
Console.WriteLine($"Эволюционируют: {canEvolve}");
|
||||||
|
Console.WriteLine($"Летают: {canFly}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IEvolvable
|
||||||
|
{
|
||||||
|
void Evolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IFlyable
|
||||||
|
{
|
||||||
|
void Fly();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Pokemon
|
||||||
|
{
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
private int level;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
name = "Безымянный";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Level
|
||||||
|
{
|
||||||
|
get { return level; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1) level = 1;
|
||||||
|
else if (value > 100) level = 100;
|
||||||
|
else level = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pokemon(string name, int level)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Attack()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Покемон атакует!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{Name} (Ур. {Level}) умеет: атаковать");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Magikarp : Pokemon
|
||||||
|
{
|
||||||
|
public Magikarp(string name, int level) : base(name, level)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Attack()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Плеск! Splash!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ничего не реализует — и это нормально
|
||||||
|
public override void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{Name} (Ур. {Level}) умеет: только атаковать (пока что...)");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Pidgeotto : Pokemon, IFlyable, IEvolvable // наследник2
|
||||||
|
{
|
||||||
|
public Pidgeotto(string name, int level) : base(name, level)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Attack()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Вжух! Порыв ветра!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Fly()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{Name} взлетает!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Evolve()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{Name} эволюционирует!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{Name} (Ур. {Level}) умеет: атаковать, летать, эволюционировать");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Charmander : Pokemon, IEvolvable // наследник3
|
||||||
|
{
|
||||||
|
public Charmander(string name, int level) : base(name, level)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Attack()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Чар-чар! Огненный хвост!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ShowInfo()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Чармандер (Ур. " + Level + "): Чар-чар! Огненный хвост!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Fly()
|
||||||
|
{
|
||||||
|
Console.WriteLine(" -> Бульбазавр взлетает на лозах!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Evolve()
|
||||||
|
{
|
||||||
|
Console.WriteLine("\n -> Бульбазавр готовится к эволюции!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
# Лабораторная работа №7
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Лабораторная работа №7:** [Тема: Тема: Наследование и полиморфизм в C#. Абстрактные классы, виртуальные методы и интерфейсы]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
class Pokemon
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public int Level;
|
||||||
|
public int HP;
|
||||||
|
|
||||||
|
|
||||||
|
public int HP
|
||||||
|
{
|
||||||
|
get { return hp; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0) hp = 0;
|
||||||
|
else if (value > 100) hp = 100;
|
||||||
|
else hp = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pikachu : Pokemon
|
||||||
|
{
|
||||||
|
public Pikachu(string name, int level) : base(name, level)
|
||||||
|
{
|
||||||
|
// тут можно добавить что-то своё
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("=== ТУРНИР: ВСЕ ПРОТИВ ВСЕХ ===");
|
||||||
|
|
||||||
|
abstract class Pokemon
|
||||||
|
{
|
||||||
|
public abstract void Attack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
=== ЗАДАНИЕ 1 ===
|
||||||
|
=== ПОКЕДЕКС ===
|
||||||
|
Имя: Пикачу, Уровень: 5, HP: 100
|
||||||
|
Имя: Сквиртл, Уровень: 5, HP: 90
|
||||||
|
=== ЗАДАНИЕ 2 ===
|
||||||
|
=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===
|
||||||
|
Попытка установить HP = -50...
|
||||||
|
Текущее HP: 0 (защита сработала)
|
||||||
|
Покемон получил 30 урона. HP: 70
|
||||||
|
Покемон вылечился. HP: 100
|
||||||
|
=== ЗАДАНИЕ 3 ===
|
||||||
|
=== ПОКЕДЕКС: СТАТИСТИКА ===
|
||||||
|
Создано покемонов: 3
|
||||||
|
=== БИТВА ===
|
||||||
|
Пикачу (Ур. 5), HP 100 против Сквиртл (Ур. 5), HP 90
|
||||||
|
Силы равны! Ничья.
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<RootNamespace>lab_07</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-07", "lab-07.csproj", "{02EF9EE4-CC3D-4279-AFAC-6CC4CA6BC983}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{02EF9EE4-CC3D-4279-AFAC-6CC4CA6BC983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{02EF9EE4-CC3D-4279-AFAC-6CC4CA6BC983}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{02EF9EE4-CC3D-4279-AFAC-6CC4CA6BC983}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{02EF9EE4-CC3D-4279-AFAC-6CC4CA6BC983}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
# Stage 1
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Техническое задание:** [Оцифровка карточки Pokémon TCG]
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson4
|
||||||
|
{
|
||||||
|
class lesson4
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите стадию развития покемона: ");
|
||||||
|
string stage = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите имя покемона: ");
|
||||||
|
string name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите вид покемона: ");
|
||||||
|
string category = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название первой атаки покемона: ");
|
||||||
|
string attack1Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект первой атаки покемона: ");
|
||||||
|
string attack1Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название второй атаки покемона: ");
|
||||||
|
string attack2Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект второй атаки покемона: ");
|
||||||
|
string attack2Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите уязвимость покемона: ");
|
||||||
|
string weakness = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите устойчивость покемона: ");
|
||||||
|
string resistance = Console.ReadLine();
|
||||||
|
int hp = 60 ;
|
||||||
|
int number = 25 ;
|
||||||
|
double height = 0.4;
|
||||||
|
double weight = 6.0;
|
||||||
|
int attack2Damage = 20 ;
|
||||||
|
int retreatCost = 1 ;
|
||||||
|
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine($"[БАЗА]{name } ОЖ: {hp} [⚡]");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"№ 0{number} | Вид: {category } | Рост: {height} м | Вес: {weight} кг");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"[Атака 1] {attack1Name} ");
|
||||||
|
Console.WriteLine($"Эффект: {attack1Desc}");
|
||||||
|
Console.WriteLine($"[Атака 2] {attack2Name} Урон: {attack2Damage}+");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine($"Эффект: {attack2Desc}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Слабость: {weakness}");
|
||||||
|
Console.WriteLine($"Устойчивость: {resistance}");
|
||||||
|
Console.WriteLine($"Отступление: {retreatCost} энергия");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
Введите стадию развития покемона:
|
||||||
|
БАЗОВЫЙ
|
||||||
|
Введите имя покемона:
|
||||||
|
Пикачу
|
||||||
|
Введите вид покемона:
|
||||||
|
Мышь
|
||||||
|
Введите название первой атаки покемона:
|
||||||
|
Электроудар
|
||||||
|
Введите эффект первой атаки покемона:
|
||||||
|
Брось монету. Если выпал орёл, активный Покемон твоего противника теперь парализован.
|
||||||
|
Введите название второй атаки покемона:
|
||||||
|
Быстрая Атака
|
||||||
|
Введите эффект второй атаки покемона:
|
||||||
|
Брось монету. Если выпал орёл, эта атака наносит на 10 пунктов урона больше.
|
||||||
|
Введите уязвимость покемона:
|
||||||
|
Боевой x2
|
||||||
|
Введите устойчивость покемона:
|
||||||
|
Стальной -20
|
||||||
|
======================================================================
|
||||||
|
[БАЗА]Пикачу ОЖ: 60 [?]
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
№ 025 | Вид: Мышь | Рост: 0,4 м | Вес: 6 кг
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
[Атака 1] Электроудар
|
||||||
|
Эффект: Брось монету. Если выпал орёл, активный Покемон твоего противника теперь парализован.
|
||||||
|
[Атака 2] Быстрая Атака Урон: 20+
|
||||||
|
|
||||||
|
Эффект: Брось монету. Если выпал орёл, эта атака наносит на 10 пунктов урона больше.
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Слабость: Боевой x2
|
||||||
|
Устойчивость: Стальной -20
|
||||||
|
Отступление: 1 энергия
|
||||||
|
======================================================================
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stage1", "stage1\stage1.csproj", "{71D87743-DF72-4E14-9309-48F353A32B98}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{71D87743-DF72-4E14-9309-48F353A32B98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{71D87743-DF72-4E14-9309-48F353A32B98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{71D87743-DF72-4E14-9309-48F353A32B98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{71D87743-DF72-4E14-9309-48F353A32B98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace lesson4
|
||||||
|
{
|
||||||
|
class lesson4
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите стадию развития покемона: ");
|
||||||
|
string stage = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите имя покемона: ");
|
||||||
|
string name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите вид покемона: ");
|
||||||
|
string category = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название первой атаки покемона: ");
|
||||||
|
string attack1Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект первой атаки покемона: ");
|
||||||
|
string attack1Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название второй атаки покемона: ");
|
||||||
|
string attack2Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект второй атаки покемона: ");
|
||||||
|
string attack2Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите уязвимость покемона: ");
|
||||||
|
string weakness = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите устойчивость покемона: ");
|
||||||
|
string resistance = Console.ReadLine();
|
||||||
|
int hp = 60 ;
|
||||||
|
int number = 25 ;
|
||||||
|
double height = 0.4;
|
||||||
|
double weight = 6.0;
|
||||||
|
int attack2Damage = 20 ;
|
||||||
|
int retreatCost = 1 ;
|
||||||
|
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine($"[БАЗА]{name } ОЖ: {hp} [⚡]");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"№ 0{number} | Вид: {category } | Рост: {height} м | Вес: {weight} кг");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"[Атака 1] {attack1Name} ");
|
||||||
|
Console.WriteLine($"Эффект: {attack1Desc}");
|
||||||
|
Console.WriteLine($"[Атака 2] {attack2Name} Урон: {attack2Damage}+");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine($"Эффект: {attack2Desc}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Слабость: {weakness}");
|
||||||
|
Console.WriteLine($"Устойчивость: {resistance}");
|
||||||
|
Console.WriteLine($"Отступление: {retreatCost} энергия");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,137 @@
|
|||||||
|
# Stage 2
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Техническое задание:** [Интерактивная механика карточки Pokémon TCG]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace stage2
|
||||||
|
{
|
||||||
|
class stage2
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine("ИНИЦИАЛИЗА КАРТОЧКИ");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
string name = "Пикачу";
|
||||||
|
string attack1Name = "Электроудар";
|
||||||
|
string attack2Name = "Быстрая Атака";
|
||||||
|
Console.Write("Введите текущее HP Пикачу: ");
|
||||||
|
int hp = int.Parse(Console.ReadLine());
|
||||||
|
Console.Write("Введите базовый урон атаки \"Быстрая Атака\": ");
|
||||||
|
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("ИСПОЛЬЗОВАНИЕ АТАК");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"[Атака 1: {attack1Name}]");
|
||||||
|
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||||
|
int coinFlip1 = int.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
if (coinFlip1 == 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Результат: Активный Покемон противника парализован!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Результат: Эффект паралича не сработал.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"\n[Атака 2: {attack2Name}]");
|
||||||
|
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||||
|
int coinFlip2 = int.Parse(Console.ReadLine());
|
||||||
|
int finalAttack2Damage = attack2BaseDamage;
|
||||||
|
|
||||||
|
if (coinFlip2 == 1)
|
||||||
|
{
|
||||||
|
finalAttack2Damage += 10;
|
||||||
|
Console.WriteLine($"Результат: Выпал орёл! Итоговый урон: {finalAttack2Damage}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Результат: Выпала решка! Итоговый урон: {finalAttack2Damage}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("\n----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("ПОЛУЧЕНИЕ УРОНА");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.Write("Введите базовый урон атаки противника: ");
|
||||||
|
int incomingDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.Write("Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): ");
|
||||||
|
int enemyAttackType = int.Parse(Console.ReadLine());
|
||||||
|
int finalIncomingDamage = incomingDamage;
|
||||||
|
|
||||||
|
switch (enemyAttackType)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
finalIncomingDamage = incomingDamage * 2;
|
||||||
|
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается (x2).");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
finalIncomingDamage = incomingDamage - 20;
|
||||||
|
|
||||||
|
if (finalIncomingDamage < 0)
|
||||||
|
{
|
||||||
|
finalIncomingDamage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Расчёт: Стальной тип! Урон уменьшается на 20 (Resistance: -20).");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Ошибка: Выбран неизвестный тип атаки!");
|
||||||
|
finalIncomingDamage = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Получено урона: {finalIncomingDamage}");
|
||||||
|
hp -= finalIncomingDamage;
|
||||||
|
if (hp <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Пикачу нокаутирован!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Пикачу выдержал удар! Остаток HP: {hp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
ИНИЦИАЛИЗА КАРТОЧКИ
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Введите текущее HP Пикачу: 60
|
||||||
|
Введите базовый урон атаки "Быстрая Атака": 20
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
ИСПОЛЬЗОВАНИЕ АТАК
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
[Атака 1: Электроудар]
|
||||||
|
Бросок монеты (1 - Орёл, 0 - Решка): 1
|
||||||
|
Результат: Активный Покемон противника парализован!
|
||||||
|
|
||||||
|
[Атака 2: Быстрая Атака]
|
||||||
|
Бросок монеты (1 - Орёл, 0 - Решка): 1
|
||||||
|
Результат: Выпал орёл! Итоговый урон: 30
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
ПОЛУЧЕНИЕ УРОНА
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Введите базовый урон атаки противника: 25
|
||||||
|
Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): 1
|
||||||
|
Расчёт: Боевой тип! Урон удваивается (x2).
|
||||||
|
Получено урона: 50
|
||||||
|
Пикачу выдержал удар! Остаток HP: 10
|
||||||
|
======================================================================
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stage2", "stage2\stage2.csproj", "{D4A0BB15-C44B-4FEA-9208-51F026C9F3A0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D4A0BB15-C44B-4FEA-9208-51F026C9F3A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D4A0BB15-C44B-4FEA-9208-51F026C9F3A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D4A0BB15-C44B-4FEA-9208-51F026C9F3A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D4A0BB15-C44B-4FEA-9208-51F026C9F3A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace lesson4
|
||||||
|
{
|
||||||
|
class lesson4
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine("ИНИЦИАЛИЗА КАРТОЧКИ");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
string name = "Пикачу";
|
||||||
|
string attack1Name = "Электроудар";
|
||||||
|
string attack2Name = "Быстрая Атака";
|
||||||
|
Console.Write("Введите текущее HP Пикачу: ");
|
||||||
|
int hp = int.Parse(Console.ReadLine());
|
||||||
|
Console.Write("Введите базовый урон атаки \"Быстрая Атака\": ");
|
||||||
|
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("ИСПОЛЬЗОВАНИЕ АТАК");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"[Атака 1: {attack1Name}]");
|
||||||
|
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||||
|
int coinFlip1 = int.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
if (coinFlip1 == 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Результат: Активный Покемон противника парализован!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Результат: Эффект паралича не сработал.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"\n[Атака 2: {attack2Name}]");
|
||||||
|
Console.Write("Бросок монеты (1 - Орёл, 0 - Решка): ");
|
||||||
|
int coinFlip2 = int.Parse(Console.ReadLine());
|
||||||
|
int finalAttack2Damage = attack2BaseDamage;
|
||||||
|
|
||||||
|
if (coinFlip2 == 1)
|
||||||
|
{
|
||||||
|
finalAttack2Damage += 10;
|
||||||
|
Console.WriteLine($"Результат: Выпал орёл! Итоговый урон: {finalAttack2Damage}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Результат: Выпала решка! Итоговый урон: {finalAttack2Damage}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("\n----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("ПОЛУЧЕНИЕ УРОНА");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.Write("Введите базовый урон атаки противника: ");
|
||||||
|
int incomingDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.Write("Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): ");
|
||||||
|
int enemyAttackType = int.Parse(Console.ReadLine());
|
||||||
|
int finalIncomingDamage = incomingDamage;
|
||||||
|
|
||||||
|
switch (enemyAttackType)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
finalIncomingDamage = incomingDamage * 2;
|
||||||
|
Console.WriteLine("Расчёт: Боевой тип! Урон удваивается (x2).");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
finalIncomingDamage = incomingDamage - 20;
|
||||||
|
|
||||||
|
if (finalIncomingDamage < 0)
|
||||||
|
{
|
||||||
|
finalIncomingDamage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Расчёт: Стальной тип! Урон уменьшается на 20 (Resistance: -20).");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Ошибка: Выбран неизвестный тип атаки!");
|
||||||
|
finalIncomingDamage = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Получено урона: {finalIncomingDamage}");
|
||||||
|
hp -= finalIncomingDamage;
|
||||||
|
if (hp <= 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Пикачу нокаутирован!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Пикачу выдержал удар! Остаток HP: {hp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,154 @@
|
|||||||
|
# Stage 3
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Техническое задание**: [Универсальный игровой цикл дуэли Pokémon TCG (Абстрактная модель)]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
namespace stage3
|
||||||
|
{
|
||||||
|
class stage3
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine("ИНИЦИАЛИЗА КАРТОЧКИ ПОКЕМОНА");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("Введите стадию развития покемона: ");
|
||||||
|
string stage = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите имя покемона: ");
|
||||||
|
string name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите вид покемона: ");
|
||||||
|
string category = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название 1-й атаки: ");
|
||||||
|
string attack1Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект 1-й атаки: ");
|
||||||
|
string attack1Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите базовый урон 1-й атаки:");
|
||||||
|
int attack1BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("Введите название 2-й атаки: ");
|
||||||
|
string attack2Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект 2-й атаки: ");
|
||||||
|
string attack2Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите базовый урон 2-й атаки: ");
|
||||||
|
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("Введите уязвимость: ");
|
||||||
|
string weakness = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите устойчивость: ");
|
||||||
|
string resistance = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите текущее HP: ");
|
||||||
|
int hp = int.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
string enemyName = "Булбазавр";
|
||||||
|
int enemyHp = 70 ;
|
||||||
|
int enemyBaseDamage = 15 ;
|
||||||
|
int roundNumber = 20 ;
|
||||||
|
int actionChoice = 1 ;
|
||||||
|
bool isEnemyDebuffed = true;
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine($"[{stage}] Чармандер ОЖ: {enemyHp}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Вид: {category}");
|
||||||
|
Console.WriteLine($"[Атака 1] {attack1Name} Урон: {attack1BaseDamage}");
|
||||||
|
Console.WriteLine($"Эффект: {attack1Desc}");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine($"[Атака 2] {attack2Name} Урон: {attack2BaseDamage}+");
|
||||||
|
Console.WriteLine($"Эффект: {attack2Desc}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Слабость: {weakness} | Устойчивость: {resistance}");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine("Приготовьтесь к дуэли!");
|
||||||
|
for (int i = 3; i > 0 ; i--)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{i}...");
|
||||||
|
}
|
||||||
|
Console.WriteLine($"=== СТАРТ ДУЭЛИ: {name} (HP: {hp}) VS {enemyName } (HP: {enemyHp}) ===\n");
|
||||||
|
while (hp > 0 && enemyHp > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||||
|
|
||||||
|
int choice;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Выберите атаку: 1 — {attack1Name}, 2 — {attack2Name}");
|
||||||
|
|
||||||
|
if (choice == 1 || choice == 2)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Неверный ввод. Введите 1 или 2.");
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
Console.WriteLine("Вы выбрали: " + choice);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (isEnemyDebuffed == true)
|
||||||
|
{
|
||||||
|
Console.WriteLine($" {enemyName} пропускает ход из-за эффекта атаки!");
|
||||||
|
|
||||||
|
}
|
||||||
|
else Console.WriteLine();
|
||||||
|
|
||||||
|
}
|
||||||
|
roundNumber++;
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ===");
|
||||||
|
if (hp > enemyHp)
|
||||||
|
{
|
||||||
|
Console.WriteLine("$\"Победитель: {name}!\"");
|
||||||
|
}
|
||||||
|
else Console.WriteLine($"Победитель: {enemyName}!");
|
||||||
|
|
||||||
|
Console.WriteLine($"Победитель: ");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
ИНИЦИАЛИЗА КАРТОЧКИ
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Введите текущее HP Пикачу: 60
|
||||||
|
Введите базовый урон атаки "Быстрая Атака": 20
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
ИСПОЛЬЗОВАНИЕ АТАК
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
[Атака 1: Электроудар]
|
||||||
|
Бросок монеты (1 - Орёл, 0 - Решка): 1
|
||||||
|
Результат: Активный Покемон противника парализован!
|
||||||
|
|
||||||
|
[Атака 2: Быстрая Атака]
|
||||||
|
Бросок монеты (1 - Орёл, 0 - Решка): 1
|
||||||
|
Результат: Выпал орёл! Итоговый урон: 30
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
ПОЛУЧЕНИЕ УРОНА
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Введите базовый урон атаки противника: 25
|
||||||
|
Выберите тип атаки противника (1 - Боевой, 2 - Стальной, 3 - Обычный): 1
|
||||||
|
Расчёт: Боевой тип! Урон удваивается (x2).
|
||||||
|
Получено урона: 50
|
||||||
|
Пикачу выдержал удар! Остаток HP: 10
|
||||||
|
======================================================================
|
||||||
|
|
||||||
|
Process finished with exit code 0.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stage3", "stage3\stage3.csproj", "{5B75339E-D323-4277-8FBB-CA008C342B84}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5B75339E-D323-4277-8FBB-CA008C342B84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5B75339E-D323-4277-8FBB-CA008C342B84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5B75339E-D323-4277-8FBB-CA008C342B84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5B75339E-D323-4277-8FBB-CA008C342B84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace stage3
|
||||||
|
{
|
||||||
|
class stage3
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine("ИНИЦИАЛИЗА КАРТОЧКИ ПОКЕМОНА");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine("Введите стадию развития покемона: ");
|
||||||
|
string stage = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите имя покемона: ");
|
||||||
|
string name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите вид покемона: ");
|
||||||
|
string category = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите название 1-й атаки: ");
|
||||||
|
string attack1Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект 1-й атаки: ");
|
||||||
|
string attack1Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите базовый урон 1-й атаки:");
|
||||||
|
int attack1BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("Введите название 2-й атаки: ");
|
||||||
|
string attack2Name = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите эффект 2-й атаки: ");
|
||||||
|
string attack2Desc = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите базовый урон 2-й атаки: ");
|
||||||
|
int attack2BaseDamage = int.Parse(Console.ReadLine());
|
||||||
|
Console.WriteLine("Введите уязвимость: ");
|
||||||
|
string weakness = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите устойчивость: ");
|
||||||
|
string resistance = Console.ReadLine();
|
||||||
|
Console.WriteLine("Введите текущее HP: ");
|
||||||
|
int hp = int.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
string enemyName = "Булбазавр";
|
||||||
|
int enemyHp = 70;
|
||||||
|
int enemyBaseDamage = 15;
|
||||||
|
int roundNumber = 1;
|
||||||
|
int actionChoice;
|
||||||
|
int attackChoice;
|
||||||
|
bool isEnemyDebuffed = false;
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine($"[{stage}] Чармандер ОЖ: {hp}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Вид: {category}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine(
|
||||||
|
$"[Атака 1] {attack1Name} Урон: {attack1BaseDamage}");
|
||||||
|
Console.WriteLine($"Эффект: {attack1Desc}");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
Console.WriteLine($"[Атака 2] {attack2Name} Урон: {attack2BaseDamage}+");
|
||||||
|
Console.WriteLine($"Эффект: {attack2Desc}");
|
||||||
|
Console.WriteLine("----------------------------------------------------------------------");
|
||||||
|
Console.WriteLine($"Слабость: {weakness} | Устойчивость: {resistance}");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
Console.WriteLine(" ");
|
||||||
|
|
||||||
|
Console.WriteLine("Приготовьтесь к дуэли!");
|
||||||
|
for (int i = 3; i > 0; i--)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{i}...");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"=== СТАРТ ДУЭЛИ: {name} (HP: {hp}) VS {enemyName} (HP: {enemyHp}) ===\n");
|
||||||
|
|
||||||
|
while (hp > 0 && enemyHp > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Write("Выберите действие (1 - Угольки, 2 - Огненный Клык): ");
|
||||||
|
attackChoice = int.Parse(Console.ReadLine());
|
||||||
|
} while (attackChoice != 1 && attackChoice != 2);
|
||||||
|
|
||||||
|
roundNumber++;
|
||||||
|
|
||||||
|
if (attackChoice == 1)
|
||||||
|
{
|
||||||
|
enemyHp -= attack1BaseDamage;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Write($"[{attack1Name}] Проверка условия спецэффекта (1 - Сработал, 0 - Нет): ");
|
||||||
|
actionChoice = int.Parse(Console.ReadLine());
|
||||||
|
} while (actionChoice != 0 && actionChoice != 1);
|
||||||
|
|
||||||
|
if (actionChoice == 0)
|
||||||
|
Console.WriteLine("Результат: Спецэффект не сработал.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isEnemyDebuffed = true;
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Результат: Спецэффект сработал! {enemyName} потерял возможность атаковать!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Write(
|
||||||
|
$"[{attack2Name}] Проверка условия спецэффекта (1 - Критический урон, 0 - Обычный): ");
|
||||||
|
actionChoice = int.Parse(Console.ReadLine());
|
||||||
|
} while (actionChoice != 0 && actionChoice != 1);
|
||||||
|
|
||||||
|
if (actionChoice == 0)
|
||||||
|
{
|
||||||
|
enemyHp -= attack2BaseDamage;
|
||||||
|
Console.WriteLine("Результат: Базовый урон: " + attack2BaseDamage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enemyHp -= (attack2BaseDamage + 10);
|
||||||
|
Console.WriteLine("Результат: Условие выполнено! Нанесен усиленный урон: " +
|
||||||
|
(attack2BaseDamage + 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enemyHp <= 0)
|
||||||
|
{
|
||||||
|
enemyHp = 0;
|
||||||
|
Console.WriteLine($"{enemyName} нокаутирован!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEnemyDebuffed == true)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"\n{enemyName} пропускает ход из-за эффекта атаки!");
|
||||||
|
isEnemyDebuffed = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Write(
|
||||||
|
$"Выберите тип атаки противника (1 - Уязвимость, 2 - Устойчивость, 3 - Обычный): ");
|
||||||
|
actionChoice = int.Parse(Console.ReadLine());
|
||||||
|
} while (actionChoice != 1 && actionChoice != 2 && actionChoice != 3);
|
||||||
|
|
||||||
|
switch (actionChoice)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
hp -= (enemyBaseDamage * 2);
|
||||||
|
Console.WriteLine($"Расчёт: Уязвимость ({weakness})! Урон удваивается (x2).");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (enemyBaseDamage < 20)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Расчёт: Устойчивость ({resistance})! Урон уменьшается на 0.");
|
||||||
|
}
|
||||||
|
else hp -= (enemyBaseDamage - 20);
|
||||||
|
|
||||||
|
Console.WriteLine($"Расчёт: Устойчивость ({resistance})! Урон уменьшается на 20.");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
hp -= enemyBaseDamage;
|
||||||
|
Console.WriteLine("Расчёт: Обычный тип! Урон наносится без изменений.");
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("=== ДУЭЛЬ ОКОНЧЕНА ===");
|
||||||
|
if (hp > enemyHp)
|
||||||
|
{
|
||||||
|
Console.WriteLine("$Победитель: {name}!");
|
||||||
|
}
|
||||||
|
else Console.WriteLine($"Победитель: {enemyName}!");
|
||||||
|
|
||||||
|
Console.WriteLine($"Победитель: ");
|
||||||
|
Console.WriteLine("======================================================================");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,196 @@
|
|||||||
|
# Задание: «Покецентр»
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Задание: «Покецентр»** [
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
using System;
|
||||||
|
namespace task
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("задача 1");
|
||||||
|
string name = "Pikachu" ;
|
||||||
|
string type = "electric";
|
||||||
|
int level = 25;
|
||||||
|
int hp = 120;
|
||||||
|
double attack = 12.5 ;
|
||||||
|
bool isShiny = false ;
|
||||||
|
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||||
|
hp += 30;
|
||||||
|
level += 1;
|
||||||
|
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||||
|
|
||||||
|
Console.WriteLine("задача 2");
|
||||||
|
string attackerType = "fire";
|
||||||
|
if (attackerType == "fire")
|
||||||
|
{
|
||||||
|
Console.WriteLine("Огонь силён против травы");
|
||||||
|
}
|
||||||
|
else if (attackerType == "water" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Вода сильна против огня");
|
||||||
|
}
|
||||||
|
else if (attackerType =="grass" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Трава сильна против воды");
|
||||||
|
}
|
||||||
|
else if (attackerType == "electric" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Электричество сильно против воды");
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Тип не изучен");
|
||||||
|
|
||||||
|
Console.WriteLine("задача 3");
|
||||||
|
string type1 = "water";
|
||||||
|
Console.Write("Урон по water от grass: x");
|
||||||
|
switch (type1)
|
||||||
|
{
|
||||||
|
case "grass":
|
||||||
|
Console.WriteLine(2.0);
|
||||||
|
break;
|
||||||
|
case "electric":
|
||||||
|
Console.WriteLine(0.5);
|
||||||
|
break;
|
||||||
|
case "fire":
|
||||||
|
Console.WriteLine(0.5);
|
||||||
|
break;
|
||||||
|
case "water":
|
||||||
|
Console.WriteLine(1.0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine(1.0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// string type2 = number switch
|
||||||
|
// {
|
||||||
|
// "grass" => "2.0",
|
||||||
|
// "electric" => "2.0",
|
||||||
|
// "fire" => "0.5",
|
||||||
|
// "water" => "0.5",
|
||||||
|
// _ => "1.0"
|
||||||
|
// };
|
||||||
|
// Console.WriteLine($"Урон по water от grass: x{type1}");
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 4");
|
||||||
|
int hp1 = 100;
|
||||||
|
int round = 0;
|
||||||
|
|
||||||
|
while (hp1 > 0)
|
||||||
|
{
|
||||||
|
round++;
|
||||||
|
hp1 -= 17;
|
||||||
|
Console.WriteLine($"Покемон продержался {round} раундов, HP = {hp1}");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
if (i == 3) continue;
|
||||||
|
if (i == 9) break;
|
||||||
|
Console.WriteLine(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 5");
|
||||||
|
|
||||||
|
List<string> team = new List<string>();
|
||||||
|
team.Add("Pikachu");
|
||||||
|
team.Add("Bulbasaur");
|
||||||
|
team.Add("Charmander");
|
||||||
|
team.Add("Zubat");
|
||||||
|
|
||||||
|
Console.WriteLine(team.Count);
|
||||||
|
Console.WriteLine(team[1]);
|
||||||
|
// foreach (string pokemon in team)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"[Предмет] -> {item}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 6");
|
||||||
|
var pokedex = new Dictionary<string, int>();
|
||||||
|
pokedex["Pikachu"] = 0;
|
||||||
|
pokedex["Bulbasaur"] = 1;
|
||||||
|
pokedex["Charmander"] = 2;
|
||||||
|
pokedex["Zubat"] = 3;
|
||||||
|
|
||||||
|
// // Проверка наличия
|
||||||
|
// if (pokedex.ContainsKey("Pikachu"))
|
||||||
|
// {
|
||||||
|
// Console.WriteLine(pokedex["Pikachu"]); // 25
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Безопасное получение
|
||||||
|
// if (pokedex.TryGetValue("Missingno", out int num))
|
||||||
|
// {
|
||||||
|
// Console.WriteLine(num);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("Нет в покедексе");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Перебор
|
||||||
|
// foreach (var pair in pokedex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"{pair.Key} -> {pair.Value}");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
задача 1
|
||||||
|
Pikachu (electric), lvl 25, HP 120, Atk 12,5, shiny: False
|
||||||
|
Pikachu (electric), lvl 26, HP 150, Atk 12,5, shiny: False
|
||||||
|
задача 2
|
||||||
|
Огонь силён против травы
|
||||||
|
задача 3
|
||||||
|
Урон по water от grass: x1
|
||||||
|
задача 4
|
||||||
|
Покемон продержался 1 раундов, HP = 83
|
||||||
|
Покемон продержался 2 раундов, HP = 66
|
||||||
|
Покемон продержался 3 раундов, HP = 49
|
||||||
|
Покемон продержался 4 раундов, HP = 32
|
||||||
|
Покемон продержался 5 раундов, HP = 15
|
||||||
|
Покемон продержался 6 раундов, HP = -2
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
1
|
||||||
|
2
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
задача 5
|
||||||
|
4
|
||||||
|
Bulbasaur
|
||||||
|
2
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "10.0.0",
|
||||||
|
"rollForward": "latestMinor",
|
||||||
|
"allowPrerelease": false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "task", "task\task.csproj", "{3070CC6A-0E11-41A9-AE22-0CAD4D1286E8}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{3070CC6A-0E11-41A9-AE22-0CAD4D1286E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3070CC6A-0E11-41A9-AE22-0CAD4D1286E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3070CC6A-0E11-41A9-AE22-0CAD4D1286E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3070CC6A-0E11-41A9-AE22-0CAD4D1286E8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
using System;
|
||||||
|
namespace task
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("задача 1");
|
||||||
|
string name = "Pikachu" ;
|
||||||
|
string type = "electric";
|
||||||
|
int level = 25;
|
||||||
|
int hp = 120;
|
||||||
|
double attack = 12.5 ;
|
||||||
|
bool isShiny = false ;
|
||||||
|
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||||
|
hp += 30;
|
||||||
|
level += 1;
|
||||||
|
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||||
|
|
||||||
|
Console.WriteLine("задача 2");
|
||||||
|
string attackerType = "fire";
|
||||||
|
if (attackerType == "fire")
|
||||||
|
{
|
||||||
|
Console.WriteLine("Огонь силён против травы");
|
||||||
|
}
|
||||||
|
else if (attackerType == "water" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Вода сильна против огня");
|
||||||
|
}
|
||||||
|
else if (attackerType =="grass" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Трава сильна против воды");
|
||||||
|
}
|
||||||
|
else if (attackerType == "electric" )
|
||||||
|
{
|
||||||
|
Console.WriteLine("Электричество сильно против воды");
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Тип не изучен");
|
||||||
|
|
||||||
|
Console.WriteLine("задача 3");
|
||||||
|
string type1 = "water";
|
||||||
|
Console.Write("Урон по water от grass: x");
|
||||||
|
switch (type1)
|
||||||
|
{
|
||||||
|
case "grass":
|
||||||
|
Console.WriteLine(2.0);
|
||||||
|
break;
|
||||||
|
case "electric":
|
||||||
|
Console.WriteLine(0.5);
|
||||||
|
break;
|
||||||
|
case "fire":
|
||||||
|
Console.WriteLine(0.5);
|
||||||
|
break;
|
||||||
|
case "water":
|
||||||
|
Console.WriteLine(1.0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine(1.0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// string type2 = number switch
|
||||||
|
// {
|
||||||
|
// "grass" => "2.0",
|
||||||
|
// "electric" => "2.0",
|
||||||
|
// "fire" => "0.5",
|
||||||
|
// "water" => "0.5",
|
||||||
|
// _ => "1.0"
|
||||||
|
// };
|
||||||
|
// Console.WriteLine($"Урон по water от grass: x{type1}");
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 4");
|
||||||
|
int hp1 = 100;
|
||||||
|
int round = 0;
|
||||||
|
|
||||||
|
while (hp1 > 0)
|
||||||
|
{
|
||||||
|
round++;
|
||||||
|
hp1 -= 17;
|
||||||
|
Console.WriteLine($"Покемон продержался {round} раундов, HP = {hp1}");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
if (i == 3) continue;
|
||||||
|
if (i == 9) break;
|
||||||
|
Console.WriteLine(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 5");
|
||||||
|
|
||||||
|
List<string> team = new List<string>();
|
||||||
|
team.Add("Pikachu");
|
||||||
|
team.Add("Bulbasaur");
|
||||||
|
team.Add("Charmander");
|
||||||
|
team.Add("Zubat");
|
||||||
|
|
||||||
|
Console.WriteLine(team.Count);
|
||||||
|
Console.WriteLine(team[1]);
|
||||||
|
// foreach (string pokemon in team)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"[Предмет] -> {item}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("задача 6");
|
||||||
|
var pokedex = new Dictionary<string, int>();
|
||||||
|
pokedex["Pikachu"] = 0;
|
||||||
|
pokedex["Bulbasaur"] = 1;
|
||||||
|
pokedex["Charmander"] = 2;
|
||||||
|
pokedex["Zubat"] = 3;
|
||||||
|
|
||||||
|
// Безопасное получение
|
||||||
|
if (pokedex.TryGetValue("Pikachu", out int num))
|
||||||
|
{
|
||||||
|
Console.WriteLine(num);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Нет в покедексе");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Перебор
|
||||||
|
foreach (var pair in pokedex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{pair.Key} -> {pair.Value}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("задача 7");
|
||||||
|
|
||||||
|
var attack1 = new Dictionary<string, int>();
|
||||||
|
attack1["tackle"] = 20;
|
||||||
|
attack1["thunder"] = 40;
|
||||||
|
attack1["quick"] = 10;
|
||||||
|
int enemyHp = 75;
|
||||||
|
int turn = 0;
|
||||||
|
while (enemyHp > 0)
|
||||||
|
{
|
||||||
|
turn++;
|
||||||
|
switch (turn % 3)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Console.WriteLine("tackle");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Console.WriteLine("thunder");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("quick");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "http://localhost:5043",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "https://localhost:7131;http://localhost:5043",
|
||||||
|
"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,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.15"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@task_HostAddress = http://localhost:5043
|
||||||
|
|
||||||
|
GET {{task_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# ==========================================
|
||||||
|
# IDE & Editors (JetBrains: Rider, IDEA, Android Studio)
|
||||||
|
# ==========================================
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
*.ipr
|
||||||
|
.vscode/
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# Database Tools (DBeaver)
|
||||||
|
# ==========================================
|
||||||
|
.dbeaver/
|
||||||
|
.eclipse/
|
||||||
|
*.dbeaver-data/
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# C# / .NET / Visual Studio / Rider builds
|
||||||
|
# ==========================================
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
out/
|
||||||
|
[D-d]ebug/
|
||||||
|
[R-r]elease/
|
||||||
|
*.userprefs
|
||||||
|
*.pidb
|
||||||
|
*.versioncontrol
|
||||||
|
*.csproj.user
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# Android Studio / Gradle / Kotlin
|
||||||
|
# ==========================================
|
||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
local.properties
|
||||||
|
.navigation/
|
||||||
|
captures/
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx/
|
||||||
|
*.apk
|
||||||
|
*.aab
|
||||||
|
*.keystore
|
||||||
|
*.jks
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# OS Generated Files & Logs
|
||||||
|
# ==========================================
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Студент: [Пузанова Анна Андреевна]
|
||||||
|
* **Группа:** [228]
|
||||||
|
* **Курс:** [2]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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,61 @@
|
|||||||
|
# Лабораторная работа №1
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```kotlin
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
println("=== 1 ЗАДАНИЕ ===")
|
||||||
|
val trainerName = "Эш Кетчум"
|
||||||
|
val homeRegion = "Канто"
|
||||||
|
val badges = 8
|
||||||
|
val pokedexCount = 150
|
||||||
|
println("=== БАЗА ДАННЫХ ТРЕНЕРОВ ===")
|
||||||
|
println("Тренер: ${trainerName}")
|
||||||
|
println("Родной регион: ${homeRegion}")
|
||||||
|
println("Значков:${badges} | Покемонов в Покедексе:${pokedexCount}")
|
||||||
|
|
||||||
|
println("=== 2 ЗАДАНИЕ ===")
|
||||||
|
print("Введите имя инспектора:")
|
||||||
|
val inspectorName = readln()
|
||||||
|
print("Введите имя тренера:")
|
||||||
|
val trainerName = readln()
|
||||||
|
print("Введите стартового покемона:")
|
||||||
|
val starterPokemon = readln()
|
||||||
|
print("Введите целевой стадион:")
|
||||||
|
val targetGym = readln()
|
||||||
|
println("****************************************")
|
||||||
|
println("ЛИЦЕНЗИЯ ТРЕНЕРА")
|
||||||
|
println("Инспектор:: ${inspectorName}")
|
||||||
|
println("Тренер: ${trainerName}[Стартер: ${starterPokemon}]")
|
||||||
|
println("Следующая цель: ${targetGym}")
|
||||||
|
println("****************************************")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
=== 1 ЗАДАНИЕ ===
|
||||||
|
=== БАЗА ДАННЫХ ТРЕНЕРОВ ===
|
||||||
|
Тренер: Эш Кетчум
|
||||||
|
Родной регион: Канто
|
||||||
|
Значков:8 | Покемонов в Покедексе:150
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
|
|
||||||
|
=== 2 ЗАДАНИЕ ===
|
||||||
|
Введите имя инспектора: Профессор Оук
|
||||||
|
Введите имя тренера: Ред
|
||||||
|
Введите стартового покемона: Чармандер
|
||||||
|
Введите целевой стадион: Стадион Вермилион Сити
|
||||||
|
****************************************
|
||||||
|
ЛИЦЕНЗИЯ ТРЕНЕРА
|
||||||
|
Инспектор: Профессор Оук
|
||||||
|
Тренер: Ред [Стартер: Чармандер]
|
||||||
|
Следующая цель: Стадион Вермилион Сити
|
||||||
|
****************************************
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
fun main() {
|
||||||
|
println("=== 1 ЗАДАНИЕ ===")
|
||||||
|
val trainerName = "Эш Кетчум"
|
||||||
|
val homeRegion = "Канто"
|
||||||
|
val badges = 8
|
||||||
|
val pokedexCount = 150
|
||||||
|
println("=== БАЗА ДАННЫХ ТРЕНЕРОВ ===")
|
||||||
|
println("Тренер: ${trainerName}")
|
||||||
|
println("Родной регион: ${homeRegion}")
|
||||||
|
println("Значков:${badges} | Покемонов в Покедексе:${pokedexCount}")
|
||||||
|
|
||||||
|
println("=== 2 ЗАДАНИЕ ===")
|
||||||
|
print("Введите имя инспектора:")
|
||||||
|
val inspectorName = readln()
|
||||||
|
print("Введите имя тренера:")
|
||||||
|
val trainerName = readln()
|
||||||
|
print("Введите стартового покемона:")
|
||||||
|
val starterPokemon = readln()
|
||||||
|
print("Введите целевой стадион:")
|
||||||
|
val targetGym = readln()
|
||||||
|
println("****************************************")
|
||||||
|
println("ЛИЦЕНЗИЯ ТРЕНЕРА")
|
||||||
|
println("Инспектор:: ${inspectorName}")
|
||||||
|
println("Тренер: ${trainerName}[Стартер: ${starterPokemon}]")
|
||||||
|
println("Следующая цель: ${targetGym}")
|
||||||
|
println("****************************************")
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,90 @@
|
|||||||
|
# Лабораторная работа №2
|
||||||
|
|
||||||
|
* **Студент:** [Пузанова Анна Андреевна]
|
||||||
|
* **Вариант / Карточка:** [Например: #025 Pikachu]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
// Самая важная часть реализации (методы, структуры, логика)
|
||||||
|
public class Card
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Hp { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
println("Задание 1. Явное приведение типов (Casting)")
|
||||||
|
print ("Текущий ход: ")
|
||||||
|
val currentTurnInputString: String = readln()
|
||||||
|
val currentTurnInput: Int = currentTurnInputString.toInt()
|
||||||
|
print ("Количество энергии на столе: ")
|
||||||
|
val energyInputString: String = readln()
|
||||||
|
val energyInput: Int = energyInputString.toInt()
|
||||||
|
print ("Коэффициент усиления атаки : ")
|
||||||
|
val multiplierInputString: String = readln()
|
||||||
|
val multiplierInput: Double = multiplierInputString.toDouble()
|
||||||
|
println("=== ИНИЦИАЛИЗАЦИЯ ПАРАМЕТРОВ ХОДА ===")
|
||||||
|
println("Текущий ход: $currentTurnInput")
|
||||||
|
println("Доступно энергии: $energyInput")
|
||||||
|
println("Множитель урона: $multiplierInput")
|
||||||
|
|
||||||
|
println("Задание 2. Математические операции и расчет эффективности хода")
|
||||||
|
var cardsPlayed = 0
|
||||||
|
println("Вывод Покемона на активную позицию!")
|
||||||
|
cardsPlayed++
|
||||||
|
print("Введите базовый урон покемона: ")
|
||||||
|
val baseDamage: Int = readln().toInt()
|
||||||
|
println("Применение карты Тренера 'Леди из Центра Покемонов'!")
|
||||||
|
cardsPlayed += 1
|
||||||
|
print("Сколько карт энергии прикрепить к Покемону? ")
|
||||||
|
val energyAttached = readln().toInt()
|
||||||
|
cardsPlayed += energyAttached
|
||||||
|
val finalDamage = baseDamage * multiplierInput
|
||||||
|
val turnCheck = currentTurnInput % 2
|
||||||
|
println("=== ХОД № 4 ===")
|
||||||
|
println("Игрок выводит Покемона на активную позицию!")
|
||||||
|
println("Введен базовый урон покемона: ${baseDamage}")
|
||||||
|
println("Применена карта Тренера 'Леди из Центра Покемонов'!")
|
||||||
|
println("Сколько карт энергии прикрепить к Покемону: ${cardsPlayed} ")
|
||||||
|
println("\n****************************************")
|
||||||
|
println("ОТЧЕТ О БОЕВОЙ ЭФФЕКТИВНОСТИ")
|
||||||
|
println("Тип хода ${turnCheck}: 0 (Четный) или 1 (Нечетный)")
|
||||||
|
println("Всего сыграно карт за ход: ${cardsPlayed}")
|
||||||
|
println("Базовый урон: ${baseDamage}")
|
||||||
|
println("Коэффициент: ${multiplierInput}")
|
||||||
|
println("Итоговый урон по противнику: ${finalDamage}")
|
||||||
|
println("****************************************")
|
||||||
|
}
|
||||||
|
|
||||||
|
ВЫВОД:
|
||||||
|
Задание 1. Явное приведение типов (Casting)
|
||||||
|
Текущий ход: 5
|
||||||
|
Количество энергии на столе: 7
|
||||||
|
Коэффициент усиления атаки : 3
|
||||||
|
=== ИНИЦИАЛИЗАЦИЯ ПАРАМЕТРОВ ХОДА ===
|
||||||
|
Текущий ход: 5
|
||||||
|
Доступно энергии: 7
|
||||||
|
Множитель урона: 3.0
|
||||||
|
Задание 2. Математические операции и расчет эффективности хода
|
||||||
|
Вывод Покемона на активную позицию!
|
||||||
|
Введите базовый урон покемона: 40
|
||||||
|
Применение карты Тренера 'Леди из Центра Покемонов'!
|
||||||
|
Сколько карт энергии прикрепить к Покемону? 2
|
||||||
|
=== ХОД № 4 ===
|
||||||
|
Игрок выводит Покемона на активную позицию!
|
||||||
|
Введите базовый урон покемона: 40
|
||||||
|
Применена карта Тренера 'Леди из Центра Покемонов'!
|
||||||
|
Сколько карт энергии прикрепить к Покемону 4?
|
||||||
|
|
||||||
|
****************************************
|
||||||
|
ОТЧЕТ О БОЕВОЙ ЭФФЕКТИВНОСТИ
|
||||||
|
Тип хода 1: 0 (Четный)
|
||||||
|
Всего сыграно карт за ход: 4
|
||||||
|
Базовый урон: 40
|
||||||
|
Коэффициент: 3.0
|
||||||
|
Итоговый урон по противнику: 120.0
|
||||||
|
****************************************
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
fun main() {
|
||||||
|
println("Задание 1. Явное приведение типов (Casting)")
|
||||||
|
print ("Текущий ход: ")
|
||||||
|
val currentTurnInputString: String = readln()
|
||||||
|
val currentTurnInput: Int = currentTurnInputString.toInt()
|
||||||
|
print ("Количество энергии на столе: ")
|
||||||
|
val energyInputString: String = readln()
|
||||||
|
val energyInput: Int = energyInputString.toInt()
|
||||||
|
print ("Коэффициент усиления атаки : ")
|
||||||
|
val multiplierInputString: String = readln()
|
||||||
|
val multiplierInput: Double = multiplierInputString.toDouble()
|
||||||
|
println("=== ИНИЦИАЛИЗАЦИЯ ПАРАМЕТРОВ ХОДА ===")
|
||||||
|
println("Текущий ход: $currentTurnInput")
|
||||||
|
println("Доступно энергии: $energyInput")
|
||||||
|
println("Множитель урона: $multiplierInput")
|
||||||
|
|
||||||
|
println("Задание 2. Математические операции и расчет эффективности хода")
|
||||||
|
var cardsPlayed = 0
|
||||||
|
println("Вывод Покемона на активную позицию!")
|
||||||
|
cardsPlayed++
|
||||||
|
print("Введите базовый урон покемона: ")
|
||||||
|
val baseDamage: Int = readln().toInt()
|
||||||
|
println("Применение карты Тренера 'Леди из Центра Покемонов'!")
|
||||||
|
cardsPlayed += 1
|
||||||
|
print("Сколько карт энергии прикрепить к Покемону? ")
|
||||||
|
val energyAttached = readln().toInt()
|
||||||
|
cardsPlayed += energyAttached
|
||||||
|
val finalDamage = baseDamage * multiplierInput
|
||||||
|
val turnCheck = currentTurnInput % 2
|
||||||
|
println("=== ХОД № 4 ===")
|
||||||
|
println("Игрок выводит Покемона на активную позицию!")
|
||||||
|
println("Введен базовый урон покемона: ${baseDamage}")
|
||||||
|
println("Применена карта Тренера 'Леди из Центра Покемонов'!")
|
||||||
|
println("Сколько карт энергии прикрепить к Покемону: ${cardsPlayed} ")
|
||||||
|
println("\n****************************************")
|
||||||
|
println("ОТЧЕТ О БОЕВОЙ ЭФФЕКТИВНОСТИ")
|
||||||
|
println("Тип хода ${turnCheck}: 0 (Четный) или 1 (Нечетный)")
|
||||||
|
println("Всего сыграно карт за ход: ${cardsPlayed}")
|
||||||
|
println("Базовый урон: ${baseDamage}")
|
||||||
|
println("Коэффициент: ${multiplierInput}")
|
||||||
|
println("Итоговый урон по противнику: ${finalDamage}")
|
||||||
|
println("****************************************")
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user