theme changed

This commit is contained in:
nik
2025-09-30 08:21:09 +03:00
parent 4c261f7def
commit 8bd93df2ae
917 changed files with 15023 additions and 0 deletions

30
labs/lab9/Igra/Gamer.cs Normal file
View File

@@ -0,0 +1,30 @@
using System;
class Gamer
{
string Name;
IgralnayaKost seans;
public Gamer(string name)
{
Name = name;
seans = new IgralnayaKost();
seans.MaxRolled += OnMaxRolled;
}
void OnMaxRolled(int value)
{
Console.WriteLine("Событие: у игрока {0} выпало максимальное количество очков ({1})", Name, value);
}
public int SeansGame()
{
return seans.random();
}
public override string ToString()
{
return Name;
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,20 @@
using System;
class IgralnayaKost
{
readonly Random r;
public event Action<int> MaxRolled;
public IgralnayaKost()
{
r = new Random();
}
public int random()
{
int res = r.Next(6) + 1;
if (res == 6) MaxRolled?.Invoke(res);
return res;
}
}

15
labs/lab9/Igra/Program.cs Normal file
View File

@@ -0,0 +1,15 @@
using System;
public class Program
{
public static void Main(string[] args)
{
Gamer g1 = new Gamer("Niko");
for (int i = 1; i <= 6; i++)
{
Console.WriteLine("Выпало количество очков {0} для игрока {1}", g1.SeansGame(), g1.ToString());
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"Igra/1.0.0": {
"runtime": {
"Igra.dll": {}
}
}
}
},
"libraries": {
"Igra/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Igra")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3d8c2bcfcb819e795b157f0ee3892cbbe80e98ce")]
[assembly: System.Reflection.AssemblyProductAttribute("Igra")]
[assembly: System.Reflection.AssemblyTitleAttribute("Igra")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
bbb674618cf86df02c0dbff2d2948ef788fa38b1e42c83cd1a3b8bdef7509517

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Igra
build_property.ProjectDir = /home/nik/oop/labs/lab9/Igra/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@@ -0,0 +1 @@
965f402a393a8b3c3615bdffcb747854f7dda4ef84f8cdb7176cc338c3ebeb3f

View File

@@ -0,0 +1,28 @@
/home/nik/oop/labs/lab7/Igra/bin/Debug/net9.0/Igra
/home/nik/oop/labs/lab7/Igra/bin/Debug/net9.0/Igra.deps.json
/home/nik/oop/labs/lab7/Igra/bin/Debug/net9.0/Igra.runtimeconfig.json
/home/nik/oop/labs/lab7/Igra/bin/Debug/net9.0/Igra.dll
/home/nik/oop/labs/lab7/Igra/bin/Debug/net9.0/Igra.pdb
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.AssemblyInfo.cs
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.dll
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/refint/Igra.dll
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.pdb
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/Igra.genruntimeconfig.cache
/home/nik/oop/labs/lab7/Igra/obj/Debug/net9.0/ref/Igra.dll
/home/nik/oop/labs/lab9/Igra/bin/Debug/net9.0/Igra
/home/nik/oop/labs/lab9/Igra/bin/Debug/net9.0/Igra.deps.json
/home/nik/oop/labs/lab9/Igra/bin/Debug/net9.0/Igra.runtimeconfig.json
/home/nik/oop/labs/lab9/Igra/bin/Debug/net9.0/Igra.dll
/home/nik/oop/labs/lab9/Igra/bin/Debug/net9.0/Igra.pdb
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.AssemblyInfo.cs
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.dll
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/refint/Igra.dll
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.pdb
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/Igra.genruntimeconfig.cache
/home/nik/oop/labs/lab9/Igra/obj/Debug/net9.0/ref/Igra.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
15568ecbe258691d0d047c49ef46a9ffa3fb09a4efabd54b9ef7f9cc3e69a4d6

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"/home/nik/oop/labs/lab9/Igra/Igra.csproj": {}
},
"projects": {
"/home/nik/oop/labs/lab9/Igra/Igra.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/Igra/Igra.csproj",
"projectName": "Igra",
"projectPath": "/home/nik/oop/labs/lab9/Igra/Igra.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/Igra/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/nik/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/nik/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.4</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/nik/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,78 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/nik/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/Igra/Igra.csproj",
"projectName": "Igra",
"projectPath": "/home/nik/oop/labs/lab9/Igra/Igra.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/Igra/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,10 @@
{
"version": 2,
"dgSpecHash": "cAalPGIUtAQ=",
"success": true,
"projectFilePath": "/home/nik/oop/labs/lab9/Igra/Igra.csproj",
"expectedPackageFiles": [
"/home/nik/.nuget/packages/microsoft.aspnetcore.app.ref/9.0.9/microsoft.aspnetcore.app.ref.9.0.9.nupkg.sha512"
],
"logs": []
}

View File

@@ -0,0 +1,29 @@
using System;
class Administrator : Person, IEmployee
{
public string Laboratory { get; }
public string Department => Laboratory;
public string Position => "Администратор";
public int Experience { get; }
public decimal BaseRate { get; }
public Administrator(string lastName, DateTime birthDate, string laboratory, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Laboratory = laboratory;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Администратор: {0}, лаб.: {1}, стаж: {2} лет, возраст: {3}", LastName, Laboratory, Experience, Age());
}
public decimal GetMonthlyPay()
{
return BaseRate * (1 + 0.05m * Experience);
}
}

View File

@@ -0,0 +1,10 @@
using System;
interface IEmployee
{
string Department { get; }
string Position { get; }
int Experience { get; }
decimal GetMonthlyPay();
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using System;
class Manager : Person, IEmployee
{
public string Faculty { get; }
public string Role { get; }
public int Experience { get; }
public decimal BaseRate { get; }
public string Department => Faculty;
public string Position => Role;
public Manager(string lastName, DateTime birthDate, string faculty, string role, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Faculty = faculty;
Role = role;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Менеджер: {0}, факультет: {1}, должность: {2}, стаж: {3} лет, возраст: {4}", LastName, Faculty, Role, Experience, Age());
}
public decimal GetMonthlyPay()
{
return BaseRate * (1 + 0.06m * Experience);
}
}

View File

@@ -0,0 +1,27 @@
using System;
abstract class Person
{
public string LastName { get; }
public DateTime BirthDate { get; }
protected Person(string lastName, DateTime birthDate)
{
LastName = lastName;
BirthDate = birthDate;
}
public int Age()
{
var today = DateTime.Today;
int a = today.Year - BirthDate.Year;
if (BirthDate.Date > today.AddYears(-a)) a--;
return a;
}
public virtual void Show()
{
Console.WriteLine("{0}, возраст: {1}", LastName, Age());
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
var people = new List<Person>
{
new Administrator("Иванова", new DateTime(1985, 3, 12), "Лаборатория сетей", 8, 900m),
new Student("Петров", new DateTime(2005, 11, 2), "ФКТИ", 2),
new Teacher("Сидоров", new DateTime(1979, 6, 25), "ФКТИ", "Доцент", 12, 1400m),
new Manager("Кузнецова", new DateTime(1990, 1, 5), "ФКТИ", "Менеджер проектов", 6, 1100m),
new Student("Орлова", new DateTime(2003, 4, 17), "ФПМИ", 4)
};
foreach (var p in people) p.Show();
Console.WriteLine();
int from = 20, to = 40;
var inRange = people.Where(p => p.Age() >= from && p.Age() <= to);
foreach (var p in inRange) p.Show();
Console.WriteLine();
foreach (var e in people.OfType<IEmployee>())
Console.WriteLine("{0}: {1}, подразделение: {2}, оклад: {3:F2}", e.GetType().Name, e.Position, e.Department, e.GetMonthlyPay());
}
}

View File

@@ -0,0 +1,20 @@
using System;
class Student : Person
{
public string Faculty { get; }
public int Course { get; }
public Student(string lastName, DateTime birthDate, string faculty, int course)
: base(lastName, birthDate)
{
Faculty = faculty;
Course = course;
}
public override void Show()
{
Console.WriteLine("Студент: {0}, факультет: {1}, курс: {2}, возраст: {3}", LastName, Faculty, Course, Age());
}
}

View File

@@ -0,0 +1,32 @@
using System;
class Teacher : Person, IEmployee
{
public string Faculty { get; }
public string Rank { get; }
public int Experience { get; }
public decimal BaseRate { get; }
public string Department => Faculty;
public string Position => Rank;
public Teacher(string lastName, DateTime birthDate, string faculty, string rank, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Faculty = faculty;
Rank = rank;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Преподаватель: {0}, факультет: {1}, должность: {2}, стаж: {3} лет, возраст: {4}", LastName, Faculty, Rank, Experience, Age());
}
public decimal GetMonthlyPay()
{
decimal mult = Rank.ToLower().Contains("проф") ? 1.4m : Rank.ToLower().Contains("доцент") ? 1.2m : 1.0m;
return BaseRate * mult * (1 + 0.04m * Experience);
}
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"LearningCenter/1.0.0": {
"runtime": {
"LearningCenter.dll": {}
}
}
}
},
"libraries": {
"LearningCenter/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("LearningCenter")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3d8c2bcfcb819e795b157f0ee3892cbbe80e98ce")]
[assembly: System.Reflection.AssemblyProductAttribute("LearningCenter")]
[assembly: System.Reflection.AssemblyTitleAttribute("LearningCenter")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
ef77545df48a5c7f7f5a2ad697fa1aea2a8429ce71d303a33ccab29bdc6ceb7b

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = LearningCenter
build_property.ProjectDir = /home/nik/oop/labs/lab9/LearningCenter/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
74bfb843dcdc21d95e467d5dda07efca3f79d59baf0577fb68e477bcc3c50e14

View File

@@ -0,0 +1,14 @@
/home/nik/oop/labs/lab9/LearningCenter/bin/Debug/net9.0/LearningCenter
/home/nik/oop/labs/lab9/LearningCenter/bin/Debug/net9.0/LearningCenter.deps.json
/home/nik/oop/labs/lab9/LearningCenter/bin/Debug/net9.0/LearningCenter.runtimeconfig.json
/home/nik/oop/labs/lab9/LearningCenter/bin/Debug/net9.0/LearningCenter.dll
/home/nik/oop/labs/lab9/LearningCenter/bin/Debug/net9.0/LearningCenter.pdb
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.AssemblyInfo.cs
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.dll
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/refint/LearningCenter.dll
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.pdb
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/LearningCenter.genruntimeconfig.cache
/home/nik/oop/labs/lab9/LearningCenter/obj/Debug/net9.0/ref/LearningCenter.dll

View File

@@ -0,0 +1 @@
2881bd5043120c29a98549d5c5a275cd667e8cdd424f573b8a90ea248583233d

Binary file not shown.

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj": {}
},
"projects": {
"/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj",
"projectName": "LearningCenter",
"projectPath": "/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/LearningCenter/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/nik/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/nik/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.4</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/nik/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,78 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/nik/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj",
"projectName": "LearningCenter",
"projectPath": "/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/LearningCenter/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,10 @@
{
"version": 2,
"dgSpecHash": "GKDBL/0OUoU=",
"success": true,
"projectFilePath": "/home/nik/oop/labs/lab9/LearningCenter/LearningCenter.csproj",
"expectedPackageFiles": [
"/home/nik/.nuget/packages/microsoft.aspnetcore.app.ref/9.0.9/microsoft.aspnetcore.app.ref.9.0.9.nupkg.sha512"
],
"logs": []
}

102
labs/lab9/MyClass/Book.cs Normal file
View File

@@ -0,0 +1,102 @@
using System;
class Book : Item
{
private String author;
private String title;
private String publisher;
private int pages;
private int year;
private static double price = 9;
private bool returnSrok = false;
static Book()
{
price = 10;
}
public Book()
{
}
public Book(String author, String title, String publisher, int pages, int year, long invNumber, bool taken) : base (invNumber, taken)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public Book(String author, String title)
{
this.author = author;
this.title = title;
}
public void SetBook(String author, String title, String publisher, int pages, int year)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public static void SetPrice(double price)
{
Book.price = price;
}
public override void Show()
{
Console.WriteLine("\nКнига:\n Автор: {0}\n Название: {1}\n Год издания: {2}\n {3} стр.\n Стоимость аренды: {4}", author, title, year, pages, Book.price);
base.Show();
}
public double PriceBook(int s)
{
double cost = s * price;
return cost;
}
public override void Return()
{
taken = ReturnSrok;
}
public delegate void ProcessBookDelegate(Book book);
public void ProcessPaperbackBooks(ProcessBookDelegate processBook)
{
if (ReturnSrok)
processBook(this);
}
public static event ProcessBookDelegate RetSrok;
public bool ReturnSrok
{
get
{
return returnSrok;
}
set
{
returnSrok = value;
if (ReturnSrok == true)
RetSrok(this);
}
}
public override string ToString()
{
string str = this.title + ", " + this.author + " Инв. номер " + this.invNumber;
return str;
}
}

47
labs/lab9/MyClass/Item.cs Normal file
View File

@@ -0,0 +1,47 @@
using System;
abstract class Item
{
protected long invNumber;
protected bool taken;
public Item(long invNumber, bool taken)
{
this.invNumber = invNumber;
this.taken = taken;
}
public Item()
{
this.taken = true;
}
public bool IsAvailable()
{
return taken;
}
public long GetInvNumber()
{
return invNumber;
}
private void Take()
{
taken = false;
}
public void TakeItem()
{
if (this.IsAvailable())
this.Take();
}
abstract public void Return();
public virtual void Show()
{
Console.WriteLine("Состояние единицы хранения:\n Инвентарный номер: {0}\n Наличие: {1}", invNumber, taken);
}
}

View File

@@ -0,0 +1,33 @@
using System;
class Magazine : Item
{
private String volume;
private int number;
private String title;
private int year;
public Magazine(String volume, int number, String title, int year, long invNumber, bool taken) : base(invNumber, taken)
{
this.volume = volume;
this.number = number;
this.title = title;
this.year = year;
}
public Magazine()
{}
public override void Show()
{
Console.WriteLine("\nЖурнал:\n Том: {0}\n Номер: {1}\n Название: {2}\n Год выпуска: {3}", volume, number, title, year);
base.Show();
}
public override void Return()
{
taken = true;
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using System;
class Operation
{
public static void PrintTitle(Book b)
{
b.Show();
}
public static void MetodObrabotchik(Book b)
{
Console.WriteLine("Книга {0} сдана в срок.", b.ToString());
}
}

View File

@@ -0,0 +1,73 @@
using System;
public class Program
{
public static void Main(string[] args)
{
/*
Book b1 = new Book();
b1.SetBook("Пушкин А.С.", "Капитанская дочка", "Вильямс", 123, 2012);
Book.SetPrice(12);
b1.Show();
Console.WriteLine("\n Итоговая стоимость аренды: {0} р.", b1.PriceBook(3));
Book b2 = new Book("Толстой Л.Н.", "Война и мир", "Наука и жизнь", 1234, 2013);
b2.Show();
Book b3 = new Book("Лермонтов М.Ю.", "Мцыри");
b3.Show();
Triangle t1 = new Triangle(3, 4, 5);
t1.Show();
Console.WriteLine("perimeter = {0}", t1.Perimeter());
Console.WriteLine("area = {0}", t1.Area());
Console.WriteLine("does this triangle exist? {0}", t1.Exists());
Triangle t2 = new Triangle(3, 4, 7);
t2.Show();
Console.WriteLine("does this triangle exist? {0}", t2.Exists());
*/
// Item item1 = new Item();
// item1.Show();
/*
Book b2 = new Book("Толстой Л. Н.", "Война и мир", "Наука и жизнь", 1234, 2013, 101, true);
b2.Show();
b2.TakeItem();
b2.Show();
Magazine mag1 = new Magazine("О природе", 5, "Земля и мы", 2014, 1235, true);
mag1.Show();
Console.WriteLine("\n Тестирование полиформизма");
Item it;
it = b2;
it.TakeItem();
it.Return();
it.Show();
it = mag1;
it.TakeItem();
it.Return();
it.Show();
*/
Book b4 = new Book("Толстой Л.Н.", "Анна Каренина", "Знание", 1204, 2014, 103, true);
Book b5 = new Book("Неш Т", "Программирование для профессионалов", "Вильямс", 1200, 2014, 108, true);
Book.RetSrok += new Book.ProcessBookDelegate(Operation.MetodObrabotchik);
b4.ReturnSrok = true;
b5.ReturnSrok = true;
Console.WriteLine("\nКниги возвращены в срок:");
b4.ProcessPaperbackBooks(Operation.PrintTitle);
b5.ProcessPaperbackBooks(Operation.PrintTitle);
}
}

View File

@@ -0,0 +1,42 @@
using System;
class Triangle
{
private int a;
private int b;
private int c;
public Triangle(int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
}
public void Show()
{
Console.WriteLine("a: {0}\nb: {1}\nc: {2}", a, b, c);
}
public int Perimeter()
{
return a + b + c;
}
public double Area()
{
double p = Perimeter() / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
public bool Exists()
{
if (a <= 0 || b <= 0 || c <= 0) return false;
double maxSide = Math.Max(Math.Max(a, b), Math.Max(b, c));
if (maxSide >= a + b + c - maxSide) return false;
return true;
}
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"MyClass/1.0.0": {
"runtime": {
"MyClass.dll": {}
}
}
}
},
"libraries": {
"MyClass/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MyClass")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3d8c2bcfcb819e795b157f0ee3892cbbe80e98ce")]
[assembly: System.Reflection.AssemblyProductAttribute("MyClass")]
[assembly: System.Reflection.AssemblyTitleAttribute("MyClass")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
5f1e2d2b133ade4a16757283d3dfb38173bab760f9f2a01cde057378fdd200f8

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net9.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = MyClass
build_property.ProjectDir = /home/nik/oop/labs/lab9/MyClass/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 9.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
b6eeb5bdef6e2c02644aaa75969222ad56a8ae5fa848f2b9a0bf36c77dbdc1fd

View File

@@ -0,0 +1,28 @@
/home/nik/oop/labs/lab7/MyClass/bin/Debug/net9.0/MyClass
/home/nik/oop/labs/lab7/MyClass/bin/Debug/net9.0/MyClass.deps.json
/home/nik/oop/labs/lab7/MyClass/bin/Debug/net9.0/MyClass.runtimeconfig.json
/home/nik/oop/labs/lab7/MyClass/bin/Debug/net9.0/MyClass.dll
/home/nik/oop/labs/lab7/MyClass/bin/Debug/net9.0/MyClass.pdb
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.AssemblyInfo.cs
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.dll
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/refint/MyClass.dll
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.pdb
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/MyClass.genruntimeconfig.cache
/home/nik/oop/labs/lab7/MyClass/obj/Debug/net9.0/ref/MyClass.dll
/home/nik/oop/labs/lab9/MyClass/bin/Debug/net9.0/MyClass
/home/nik/oop/labs/lab9/MyClass/bin/Debug/net9.0/MyClass.deps.json
/home/nik/oop/labs/lab9/MyClass/bin/Debug/net9.0/MyClass.runtimeconfig.json
/home/nik/oop/labs/lab9/MyClass/bin/Debug/net9.0/MyClass.dll
/home/nik/oop/labs/lab9/MyClass/bin/Debug/net9.0/MyClass.pdb
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.GeneratedMSBuildEditorConfig.editorconfig
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.AssemblyInfoInputs.cache
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.AssemblyInfo.cs
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.csproj.CoreCompileInputs.cache
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.dll
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/refint/MyClass.dll
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.pdb
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/MyClass.genruntimeconfig.cache
/home/nik/oop/labs/lab9/MyClass/obj/Debug/net9.0/ref/MyClass.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
d590c4e74bd8755742999ea3cdcebb807222eb4693e8da32b2ee5d12d5003488

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"/home/nik/oop/labs/lab9/MyClass/MyClass.csproj": {}
},
"projects": {
"/home/nik/oop/labs/lab9/MyClass/MyClass.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/MyClass/MyClass.csproj",
"projectName": "MyClass",
"projectPath": "/home/nik/oop/labs/lab9/MyClass/MyClass.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/MyClass/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/nik/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/nik/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.4</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/home/nik/.nuget/packages/" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,78 @@
{
"version": 3,
"targets": {
"net9.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net9.0": []
},
"packageFolders": {
"/home/nik/.nuget/packages/": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/home/nik/oop/labs/lab9/MyClass/MyClass.csproj",
"projectName": "MyClass",
"projectPath": "/home/nik/oop/labs/lab9/MyClass/MyClass.csproj",
"packagesPath": "/home/nik/.nuget/packages/",
"outputPath": "/home/nik/oop/labs/lab9/MyClass/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/home/nik/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net9.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.100"
},
"frameworks": {
"net9.0": {
"targetAlias": "net9.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[9.0.9, 9.0.9]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/9.0.110/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,10 @@
{
"version": 2,
"dgSpecHash": "foRFbJcq8dk=",
"success": true,
"projectFilePath": "/home/nik/oop/labs/lab9/MyClass/MyClass.csproj",
"expectedPackageFiles": [
"/home/nik/.nuget/packages/microsoft.aspnetcore.app.ref/9.0.9/microsoft.aspnetcore.app.ref.9.0.9.nupkg.sha512"
],
"logs": []
}

BIN
labs/lab9/assets/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
labs/lab9/assets/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

BIN
labs/lab9/assets/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
labs/lab9/assets/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

BIN
labs/lab9/report.pdf Normal file

Binary file not shown.

649
labs/lab9/report.typ Normal file
View File

@@ -0,0 +1,649 @@
#set text(size: 1.3em)
#show raw.where(block: false): box.with(
fill: luma(240),
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)
#show raw.where(block: true): block.with(
fill: luma(240),
inset: 10pt,
radius: 4pt,
)
// title
#align(center)[Санкт-Петербургский национальный исследовательский университет информационных технологий, механики и оптики]
\
\
\
#align(center)[Факультет инфокоммуникационных технологий]
#align(center)[Направление подготовки 11.03.02]
\
\
#align(center)[Лабораторная работа №9]
#align(center)[Применение делегатов и событий]
\
\
\ //#align(center)[Вариант 19]
\
\
\
\
\
\
\
#align(right)[Выполнил:]
#align(right)[Дощенников Никита Андреевич]
#align(right)[Группа: К3221]
#align(right)[Проверил:]
#align(right)[Иванов Сергей Евгеньевич]
\
\
#align(center)[Санкт-Петербург]
#align(center)[2025]
#pagebreak()
=== Цель работы:
Научиться работать с делегатами и событиями и применять их.
=== Упражнение 1. Использование делегата при вызове метода.
В этом упражнении я реализовал в классе `Book` возможность вызова метода через делегат.
```cs
using System;
class Operation
{
public static void PrintTitle(Book b)
{
b.Show();
}
}
```
```cs
using System;
class Book : Item
{
private String author;
private String title;
private String publisher;
private int pages;
private int year;
private static double price = 9;
static Book()
{
price = 10;
}
public Book()
{
}
public Book(String author, String title, String publisher, int pages, int year, long invNumber, bool taken) : base (invNumber, taken)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public Book(String author, String title)
{
this.author = author;
this.title = title;
}
public void SetBook(String author, String title, String publisher, int pages, int year)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public static void SetPrice(double price)
{
Book.price = price;
}
public override void Show()
{
Console.WriteLine("\nКнига:\n Автор: {0}\n Название: {1}\n Год издания: {2}\n {3} стр.\n Стоимость аренды: {4}", author, title, year, pages, Book.price);
base.Show();
}
public double PriceBook(int s)
{
double cost = s * price;
return cost;
}
public override void Return()
{
taken = ReturnSrok;
}
public delegate void ProcessBookDelegate(Book book);
public bool ReturnSrok { get; set; }
public void ProcessPaperbackBooks(ProcessBookDelegate processBook)
{
if (ReturnSrok)
processBook(this);
}
}
```
Тесты:
```cs
public static void Main(string[] args)
{
Book b4 = new Book("Толстой Л.Н.", "Анна Каренина", "Знание", 1204, 2014, 103, true);
Book b5 = new Book("Неш Т", "Программирование для профессионалов", "Вильямс", 1200, 2014, 108, true);
b4.ReturnSrok = true;
b5.ReturnSrok = false;
Console.WriteLine("\nКниги возвращены в срок:");
b4.ProcessPaperbackBooks(Operation.PrintTitle);
b5.ProcessPaperbackBooks(Operation.PrintTitle);
}
```
Пример:
#align(center)[#image("assets/1.png")]
=== Упражнение 2. Работа с событиями.
В этом упражнении я в классе `Book` объявил событие "возвращение книги в срок", и объекты этого класса смогли уведомлять объекты других классов о данном событии.
```cs
using System;
class Book : Item
{
private String author;
private String title;
private String publisher;
private int pages;
private int year;
private static double price = 9;
private bool returnSrok = false;
static Book()
{
price = 10;
}
public Book()
{
}
public Book(String author, String title, String publisher, int pages, int year, long invNumber, bool taken) : base (invNumber, taken)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public Book(String author, String title)
{
this.author = author;
this.title = title;
}
public void SetBook(String author, String title, String publisher, int pages, int year)
{
this.author = author;
this.title = title;
this.publisher = publisher;
this.pages = pages;
this.year = year;
}
public static void SetPrice(double price)
{
Book.price = price;
}
public override void Show()
{
Console.WriteLine("\nКнига:\n Автор: {0}\n Название: {1}\n Год издания: {2}\n {3} стр.\n Стоимость аренды: {4}", author, title, year, pages, Book.price);
base.Show();
}
public double PriceBook(int s)
{
double cost = s * price;
return cost;
}
public override void Return()
{
taken = ReturnSrok;
}
public delegate void ProcessBookDelegate(Book book);
public void ProcessPaperbackBooks(ProcessBookDelegate processBook)
{
if (ReturnSrok)
processBook(this);
}
public static event ProcessBookDelegate RetSrok;
public bool ReturnSrok
{
get
{
return returnSrok;
}
set
{
returnSrok = value;
if (ReturnSrok == true)
RetSrok(this);
}
}
public override string ToString()
{
string str = this.title + ", " + this.author + " Инв. номер " + this.invNumber;
return str;
}
}
```
```cs
using System;
class Operation
{
public static void PrintTitle(Book b)
{
b.Show();
}
public static void MetodObrabotchik(Book b)
{
Console.WriteLine("Книга {0} сдана в срок.", b.ToString());
}
}
```
Тесты:
```cs
public static void Main(string[] args)
{
Book b4 = new Book("Толстой Л.Н.", "Анна Каренина", "Знание", 1204, 2014, 103, true);
Book b5 = new Book("Неш Т", "Программирование для профессионалов", "Вильямс", 1200, 2014, 108, true);
Book.RetSrok += new Book.ProcessBookDelegate(Operation.MetodObrabotchik);
b4.ReturnSrok = true;
b5.ReturnSrok = true;
Console.WriteLine("\nКниги возвращены в срок:");
b4.ProcessPaperbackBooks(Operation.PrintTitle);
b5.ProcessPaperbackBooks(Operation.PrintTitle);
}
```
Пример:
#align(center)[#image("assets/2.png")]
=== Упражнение 3. Реализация события.
В этом упражнении в проекте `IgralnayaKost` я реализовал возникновение события "выпало максимальное количество очков" при броске игрального кубика.
```cs
using System;
class Gamer
{
string Name;
IgralnayaKost seans;
public Gamer(string name)
{
Name = name;
seans = new IgralnayaKost();
seans.MaxRolled += OnMaxRolled;
}
void OnMaxRolled(int value)
{
Console.WriteLine("Событие: у игрока {0} выпало максимальное количество очков ({1})", Name, value);
}
public int SeansGame()
{
return seans.random();
}
public override string ToString()
{
return Name;
}
}
```
```cs
using System;
class IgralnayaKost
{
readonly Random r;
public event Action<int> MaxRolled;
public IgralnayaKost()
{
r = new Random();
}
public int random()
{
int res = r.Next(6) + 1;
if (res == 6) MaxRolled?.Invoke(res);
return res;
}
}
```
Тесты:
```cs
public static void Main(string[] args)
{
Gamer g1 = new Gamer("Niko");
for (int i = 1; i <= 6; i++)
{
Console.WriteLine("Выпало количество очков {0} для игрока {1}", g1.SeansGame(), g1.ToString());
}
}
```
Пример:
#align(center)[#image("assets/3.png")]
=== Упражнение 4. Иерархия классов учебного центра.
В этом задании я реализовал иерархию классов учебного центра.
```cs
using System;
class Administrator : Person, IEmployee
{
public string Laboratory { get; }
public string Department => Laboratory;
public string Position => "Администратор";
public int Experience { get; }
public decimal BaseRate { get; }
public Administrator(string lastName, DateTime birthDate, string laboratory, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Laboratory = laboratory;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Администратор: {0}, лаб.: {1}, стаж: {2} лет, возраст: {3}", LastName, Laboratory, Experience, Age());
}
public decimal GetMonthlyPay()
{
return BaseRate * (1 + 0.05m * Experience);
}
}
```
```cs
using System;
interface IEmployee
{
string Department { get; }
string Position { get; }
int Experience { get; }
decimal GetMonthlyPay();
}
```
```cs
using System;
class Manager : Person, IEmployee
{
public string Faculty { get; }
public string Role { get; }
public int Experience { get; }
public decimal BaseRate { get; }
public string Department => Faculty;
public string Position => Role;
public Manager(string lastName, DateTime birthDate, string faculty, string role, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Faculty = faculty;
Role = role;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Менеджер: {0}, факультет: {1}, должность: {2}, стаж: {3} лет, возраст: {4}", LastName, Faculty, Role, Experience, Age());
}
public decimal GetMonthlyPay()
{
return BaseRate * (1 + 0.06m * Experience);
}
}
```
```cs
using System;
abstract class Person
{
public string LastName { get; }
public DateTime BirthDate { get; }
protected Person(string lastName, DateTime birthDate)
{
LastName = lastName;
BirthDate = birthDate;
}
public int Age()
{
var today = DateTime.Today;
int a = today.Year - BirthDate.Year;
if (BirthDate.Date > today.AddYears(-a)) a--;
return a;
}
public virtual void Show()
{
Console.WriteLine("{0}, возраст: {1}", LastName, Age());
}
}
```
```cs
using System;
class Student : Person
{
public string Faculty { get; }
public int Course { get; }
public Student(string lastName, DateTime birthDate, string faculty, int course)
: base(lastName, birthDate)
{
Faculty = faculty;
Course = course;
}
public override void Show()
{
Console.WriteLine("Студент: {0}, факультет: {1}, курс: {2}, возраст: {3}", LastName, Faculty, Course, Age());
}
}
```
```cs
using System;
class Teacher : Person, IEmployee
{
public string Faculty { get; }
public string Rank { get; }
public int Experience { get; }
public decimal BaseRate { get; }
public string Department => Faculty;
public string Position => Rank;
public Teacher(string lastName, DateTime birthDate, string faculty, string rank, int experience, decimal baseRate)
: base(lastName, birthDate)
{
Faculty = faculty;
Rank = rank;
Experience = experience;
BaseRate = baseRate;
}
public override void Show()
{
Console.WriteLine("Преподаватель: {0}, факультет: {1}, должность: {2}, стаж: {3} лет, возраст: {4}", LastName, Faculty, Rank, Experience, Age());
}
public decimal GetMonthlyPay()
{
decimal mult = Rank.ToLower().Contains("проф") ? 1.4m : Rank.ToLower().Contains("доцент") ? 1.2m : 1.0m;
return BaseRate * mult * (1 + 0.04m * Experience);
}
}
```
Тесты:
```cs
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
var people = new List<Person>
{
new Administrator("Иванова", new DateTime(1985, 3, 12), "Лаборатория сетей", 8, 900m),
new Student("Петров", new DateTime(2005, 11, 2), "ФКТИ", 2),
new Teacher("Сидоров", new DateTime(1979, 6, 25), "ФКТИ", "Доцент", 12, 1400m),
new Manager("Кузнецова", new DateTime(1990, 1, 5), "ФКТИ", "Менеджер проектов", 6, 1100m),
new Student("Орлова", new DateTime(2003, 4, 17), "ФПМИ", 4)
};
foreach (var p in people) p.Show();
Console.WriteLine();
int from = 20, to = 40;
var inRange = people.Where(p => p.Age() >= from && p.Age() <= to);
foreach (var p in inRange) p.Show();
Console.WriteLine();
foreach (var e in people.OfType<IEmployee>())
Console.WriteLine("{0}: {1}, подразделение: {2}, оклад: {3:F2}", e.GetType().Name, e.Position, e.Department, e.GetMonthlyPay());
}
}
```
Пример:
#align(center)[#image("assets/4.png")]
=== Вывод.
В ходе проделанной работы я научился работать с делегатами и событиями и применять их.
=== Code review. (by #link("https://zzzcode.ai")[zzzcode.ai])
*Резюме*
Код представляет собой реализацию игры с использованием классов для игроков и игральных костей. Основные функции включают генерацию случайных значений и обработку событий. В целом, код хорошо структурирован, но требует некоторых улучшений в области стиля и читаемости.
*Ошибка*
В методе `random()` класса `IgralnayaKost` название метода не соответствует стандартам именования в C\#. Рекомендуется переименовать его в `Roll()` для лучшего понимания.
*Стиль кода*
Код в целом следует стандартам C\#, однако есть некоторые моменты, которые можно улучшить: Имена переменных и методов должны быть написаны в стиле `PascalCase`. Необходимо использовать явные модификаторы доступа (например, `public`, `private`) для всех членов класса.
*Структура кода*
Структура классов логична, однако стоит рассмотреть возможность разделения на отдельные файлы для каждого класса, чтобы улучшить организацию проекта и упростить навигацию.
*Читаемость*
Читаемость кода можно улучшить, добавив комментарии к методам и классам, а также следуя единообразному стилю именования. Например, использование `seans` как имени переменной может быть неочевидным для других разработчиков.
*Производительность*
Код работает эффективно для текущих задач, однако стоит обратить внимание на создание экземпляра `Random` в каждом вызове. Рекомендуется создать один экземпляр `Random` и использовать его повторно.
*Масштабируемость*
Код легко масштабируется, так как добавление новых типов игроков или игральных костей не требует значительных изменений в существующей логике. Однако стоит учитывать возможность добавления новых функций и их влияние на текущую архитектуру.
*Безопасность*
Код не содержит явных уязвимостей, однако стоит учитывать обработку исключений, особенно в методах, которые могут вызывать ошибки, например, при работе с пользовательским вводом.
*Обработка ошибок*
В текущем коде отсутствует обработка ошибок. Рекомендуется добавить обработку исключений, чтобы предотвратить сбои программы в случае неожиданных ситуаций.
*Заключение*
Код представляет собой хорошую основу для игры, но требует некоторых улучшений в области стиля, читаемости и обработки ошибок. Рекомендуется внести предложенные изменения для повышения качества и удобства работы с кодом.