Compare commits

...

3 Commits
main ... laba2

Author SHA1 Message Date
Учебный
bd494d4f70 зафиксировать всё 2023-10-29 14:18:39 +04:00
Учебный
2f8114f6f8 обязательно 2023-10-16 12:31:25 +04:00
Учебный
b314ff775d обязательно 2023-10-14 16:22:19 +04:00
29 changed files with 4241 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectBoat_bae", "ProjectBoat_bae\ProjectBoat_bae.csproj", "{D8469CDA-6475-44BF-BCDE-A69B80397FE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8469CDA-6475-44BF-BCDE-A69B80397FE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8469CDA-6475-44BF-BCDE-A69B80397FE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8469CDA-6475-44BF-BCDE-A69B80397FE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8469CDA-6475-44BF-BCDE-A69B80397FE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {13897BDF-00CA-4062-A354-314E6E63DC45}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae
{
public enum DiretionType
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using ProjectBoat_bae;
using ProjectBoat_bae.Entities;
namespace ProjectBoat_bae.DrawningObjects
{
public class Drawningboat
{
// Класс-сущность
public EntityBoat? EntityBoat { get; protected set; }
// Ширина окна
private int _pictureWidth;
// Высота окна
private int _pictureHeight;
// Левая координата прорисовки
protected int _startPosX;
// Верхняя кооридната прорисовки
protected int _startPosY;
// Ширина прорисовки
protected readonly int _boatWidth = 80;
// Высота прорисовки
protected readonly int _boatHeight = 50;
public int GetPosX => _startPosX;
public int GetPosY => _startPosY;
public int GetWidth => _boatWidth;
public int GetHeight => _boatHeight;
// Конструктор
public Drawningboat(int speed, double weight, Color bodyColor, int
width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (width < _pictureWidth || height < _pictureHeight)
{
return;
}
EntityBoat = new EntityBoat(speed, weight, bodyColor);
}
protected Drawningboat(int speed, double weight, Color bodyColor, int
width, int height, int boatWidth, int boatHeight)
{
if (width < _boatWidth || height < _boatHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
_boatWidth = boatWidth;
_boatHeight = boatHeight;
EntityBoat = new EntityBoat(speed, weight, bodyColor);
}
// Установка позиции
public void SetPosition(int x, int y)
{
_startPosX = Math.Min(x, _pictureWidth - _boatWidth);
_startPosY = Math.Min(y, _pictureHeight - _boatHeight);
}
// Прорисовка объекта
public virtual void DrawTransport(Graphics g)
{
if (EntityBoat == null)
{
return;
}
Pen pen = new(Color.Black);
//корпус
Brush br = new SolidBrush(EntityBoat.BodyColor);
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
//мотор
Brush brRed = new SolidBrush(EntityBoat.BodyColor);
g.FillEllipse(brRed, _startPosX + 7, _startPosY + 12, 35, 35);
//стекла
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5,
40);
g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, 2);
g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, 2);
}
// Проверка, что объект может переместится по указанному направлению
public bool CanMove(DiretionType direction)
{
if (EntityBoat == null)
{
return false;
}
return direction switch
{
//влево
DiretionType.Left => _startPosX - EntityBoat.Step > 0,
//вверх
DiretionType.Up => _startPosY - EntityBoat.Step > 0,
// вправо
DiretionType.Right => _startPosX + EntityBoat.Step < _pictureWidth,
//вниз
DiretionType.Down => _startPosY + EntityBoat.Step < _pictureHeight,
_ => false
};
}
// Изменение направления перемещения
public void MoveTransport(DiretionType direction)
{
if (!CanMove(direction) || EntityBoat == null)
{
return;
}
switch (direction)
{
//влево
case DiretionType.Left:
if (_startPosX - EntityBoat.Step > 0)
{
_startPosX -= (int)EntityBoat.Step;
}
break;
//вверх
case DiretionType.Up:
if (_startPosY - EntityBoat.Step > 0)
{
_startPosY -= (int)EntityBoat.Step;
}
break;
// вправо
case DiretionType.Right:
if (_startPosX + EntityBoat.Step + _boatWidth < _pictureWidth)
{
_startPosX += (int)EntityBoat.Step;
}
break;
//вниз
case DiretionType.Down:
if (_startPosY + EntityBoat.Step + _boatHeight < _pictureHeight)
{
_startPosY += (int)EntityBoat.Step;
}
break;
}
}
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using ProjectBoat_bae.Entities;
namespace ProjectBoat_bae.DrawningObjects
{
public class DrawningMotorBoat : Drawningboat
{
public DrawningMotorBoat(int speed, double weight, Color bodyColor, Color
additionalColor, bool body, bool wing,
int width, int height) : base(speed, weight, bodyColor, width, height, 110, 60)
{
if (EntityBoat != null)
{
EntityBoat = new EntityMotorBoat(speed, weight, bodyColor,
additionalColor, body, wing);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityBoat is not EntityMotorBoat Boat)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(Boat.AdditionalColor);
Brush br = new SolidBrush(EntityBoat.BodyColor);
Brush brRed = new SolidBrush(EntityBoat.BodyColor);
Brush brBlue = new SolidBrush(Color.LightBlue);
if (Boat.Body)
{
//вёсла
g.FillRectangle(brRed, _startPosX + 35, _startPosY - 5, 5, 65);
g.FillRectangle(brRed, _startPosX + 28, _startPosY + 60, 12, 8);
g.FillRectangle(brRed, _startPosX + 28, _startPosY - 5, 12, 8);
}
base.DrawTransport(g);
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.Entities
{
public class EntityBoat
{
public int Speed { get; private set; }
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public double Step => (double)Speed * 100 / Weight;
public EntityBoat(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.Entities
{
public class EntityMotorBoat : EntityBoat
{
public Color AdditionalColor { get; private set; }
public bool Body { get; private set; }
public bool Wing { get; private set; }
public EntityMotorBoat(int speed, double weight, Color bodyColor, Color
additionalColor, bool body, bool wing) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Body = body;
Wing = wing;
}
}
}

View File

@ -0,0 +1,180 @@
namespace ProjectBoat_bae
{
partial class FormBoat
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBoat));
pictureBox1 = new PictureBox();
button_bottom = new Button();
button_top = new Button();
button_right = new Button();
button_left = new Button();
buttonClick = new Button();
buttonClickMotorBoat = new Button();
buttonStep = new Button();
comboBoxStrategy = new ComboBox();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// pictureBox1
//
pictureBox1.Dock = DockStyle.Fill;
pictureBox1.Location = new Point(0, 0);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(1178, 644);
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
// button_bottom
//
button_bottom.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button_bottom.BackColor = SystemColors.ButtonHighlight;
button_bottom.BackgroundImage = (Image)resources.GetObject("button_bottom.BackgroundImage");
button_bottom.BackgroundImageLayout = ImageLayout.Zoom;
button_bottom.Location = new Point(1082, 591);
button_bottom.Name = "button_bottom";
button_bottom.Size = new Size(30, 30);
button_bottom.TabIndex = 2;
button_bottom.UseVisualStyleBackColor = false;
button_bottom.Click += buttonMove_Click;
//
// button_top
//
button_top.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button_top.BackColor = SystemColors.ButtonHighlight;
button_top.BackgroundImage = (Image)resources.GetObject("button_top.BackgroundImage");
button_top.BackgroundImageLayout = ImageLayout.Zoom;
button_top.Location = new Point(1082, 549);
button_top.Name = "button_top";
button_top.Size = new Size(30, 30);
button_top.TabIndex = 3;
button_top.UseVisualStyleBackColor = false;
button_top.Click += buttonMove_Click;
//
// button_right
//
button_right.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button_right.BackColor = SystemColors.ButtonHighlight;
button_right.BackgroundImage = (Image)resources.GetObject("button_right.BackgroundImage");
button_right.BackgroundImageLayout = ImageLayout.Zoom;
button_right.Location = new Point(1114, 573);
button_right.Name = "button_right";
button_right.Size = new Size(30, 30);
button_right.TabIndex = 4;
button_right.UseVisualStyleBackColor = false;
button_right.Click += buttonMove_Click;
//
// button_left
//
button_left.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button_left.BackColor = SystemColors.ButtonHighlight;
button_left.BackgroundImage = (Image)resources.GetObject("button_left.BackgroundImage");
button_left.BackgroundImageLayout = ImageLayout.Zoom;
button_left.Location = new Point(1051, 572);
button_left.Name = "button_left";
button_left.Size = new Size(30, 30);
button_left.TabIndex = 5;
button_left.UseVisualStyleBackColor = false;
button_left.Click += buttonMove_Click;
//
// buttonClick
//
buttonClick.Location = new Point(12, 598);
buttonClick.Name = "buttonClick";
buttonClick.Size = new Size(233, 34);
buttonClick.TabIndex = 6;
buttonClick.Text = "Создать лодку";
buttonClick.UseVisualStyleBackColor = true;
buttonClick.Click += buttonClick_Click;
//
// buttonClickMotorBoat
//
buttonClickMotorBoat.Location = new Point(261, 598);
buttonClickMotorBoat.Name = "buttonClickMotorBoat";
buttonClickMotorBoat.Size = new Size(233, 34);
buttonClickMotorBoat.TabIndex = 7;
buttonClickMotorBoat.Text = "Создать моторную лодку";
buttonClickMotorBoat.UseVisualStyleBackColor = true;
buttonClickMotorBoat.Click += buttonClickMotorBoat_Click;
//
// buttonStep
//
buttonStep.Location = new Point(1093, 45);
buttonStep.Name = "buttonStep";
buttonStep.Size = new Size(73, 36);
buttonStep.TabIndex = 8;
buttonStep.Text = "шаг";
buttonStep.UseVisualStyleBackColor = true;
buttonStep.Click += buttonStep_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.BackColor = SystemColors.ControlLight;
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
comboBoxStrategy.Location = new Point(984, 6);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(182, 33);
comboBoxStrategy.TabIndex = 9;
//
// FormBoat
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1178, 644);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonStep);
Controls.Add(buttonClickMotorBoat);
Controls.Add(buttonClick);
Controls.Add(button_left);
Controls.Add(button_right);
Controls.Add(button_top);
Controls.Add(button_bottom);
Controls.Add(pictureBox1);
Name = "FormBoat";
Text = "Form1";
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private PictureBox pictureBox1;
private Button button_bottom;
private Button button_top;
private Button button_right;
private Button button_left;
private Button buttonClick;
private Button buttonClickMotorBoat;
private Button buttonStep;
private ComboBox comboBoxStrategy;
}
}

View File

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectBoat_bae;
using ProjectBoat_bae.Properties;
using ProjectBoat_bae.Entities;
using ProjectBoat_bae.MovementStrategy;
using ProjectBoat_bae.DrawningObjects;
namespace ProjectBoat_bae
{
public partial class FormBoat : Form
{
// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
private Drawningboat? _drawingBoat;
private AbstractStrategy? _abstractStrategy;
public FormBoat()
{
InitializeComponent();
}
// Ìåòîä ïðîðèñîâêè
private void Draw()
{
if (_drawingBoat == null)
{
return;
}
Bitmap bmp = new(pictureBox1.Width,
pictureBox1.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingBoat.DrawTransport(gr);
pictureBox1.Image = bmp;
}
// Èçìåíåíèå ðàçìåðîâ ôîðìû
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawingBoat == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "button_top":
_drawingBoat.MoveTransport(DiretionType.Up);
break;
case "button_bottom":
_drawingBoat.MoveTransport(DiretionType.Down);
break;
case "button_left":
_drawingBoat.MoveTransport(DiretionType.Left);
break;
case "button_right":
_drawingBoat.MoveTransport(DiretionType.Right);
break;
}
Draw();
}
private void buttonClickMotorBoat_Click(object sender, EventArgs e)
{
Random random = new Random();
_drawingBoat = new DrawningMotorBoat(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonClick_Click(object sender, EventArgs e)
{
Random random = new();
_drawingBoat = new Drawningboat(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonStep_Click(object sender, EventArgs e)
{
if (_drawingBoat == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_abstractStrategy = comboBoxStrategy.SelectedIndex
switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.SetData(new DrawningObjectBoat(_drawingBoat), pictureBox1.Width, pictureBox1.Height);
comboBoxStrategy.Enabled = false;
}
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.MakeStep();
Draw();
if (_abstractStrategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_abstractStrategy = null;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace ProjectBoat_bae.MovementStrategy
{
public abstract class AbstractStrategy
{
// Перемещаемый объект
private IMoveableObject? _moveableObject;
// Статус перемещения
private Status _state = Status.NotInit;
// Ширина поля
protected int FieldWidth { get; private set; }
// Высота поля
protected int FieldHeight { get; private set; }
// Статус перемещения
public Status GetStatus() { return _state; }
public void SetData(IMoveableObject moveableObject, int width, int
height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
// Шаг перемещения
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
// Перемещение влево
protected bool MoveLeft() => MoveTo(DiretionType.Left);
// Перемещение вправо
protected bool MoveRight() => MoveTo(DiretionType.Right);
// Перемещение вверх
protected bool MoveUp() => MoveTo(DiretionType.Up);
// Перемещение вниз
protected bool MoveDown() => MoveTo(DiretionType.Down);
// Параметры объекта
protected ObjectParameters? GetObjectParameters =>
_moveableObject?.GetObjectPosition;
// Шаг объекта
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
// Перемещение к цели
protected abstract void MoveToTarget();
// Достигнута ли цель
protected abstract bool IsTargetDestinaion();
// Попытка перемещения в требуемом направлении
private bool MoveTo(DiretionType directionType)
{
if (_state != Status.InProgress)
{
return false;
}
if (_moveableObject?.CheckCanMove(directionType) ?? false)
{
_moveableObject.MoveObject(directionType);
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using ProjectBoat_bae;
using ProjectBoat_bae.Entities;
using ProjectBoat_bae.DrawningObjects;
namespace ProjectBoat_bae.MovementStrategy
{
// Реализация интерфейса для работы с объектом DrawningBoat!
public class DrawningObjectBoat : IMoveableObject
{
private readonly Drawningboat? _drawingBoat = null;
public DrawningObjectBoat(Drawningboat drawingBoat)
{
_drawingBoat = drawingBoat;
}
//!
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawingBoat == null || _drawingBoat.EntityBoat == null)
{
return null;
}
return new ObjectParameters(_drawingBoat.GetPosX,
_drawingBoat.GetPosY, _drawingBoat.GetWidth, _drawingBoat.GetHeight);
}
}
public int GetStep => (int)(_drawingBoat?.EntityBoat?.Step ?? 0);
public bool CheckCanMove(DiretionType direction) => _drawingBoat?.CanMove(direction) ?? false;
public void MoveObject(DiretionType direction) => _drawingBoat?.MoveTransport(direction);
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.MovementStrategy
{
public interface IMoveableObject
{
// Получение координаты X объекта
ObjectParameters? GetObjectPosition { get; }
// Шаг объектa
int GetStep { get; }
// Проверка, можно ли переместиться по нужному направлению
bool CheckCanMove(DiretionType direction);
// Изменение направления пермещения объекта
void MoveObject(DiretionType direction);
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.MovementStrategy
{
public class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.RightBorder <= FieldWidth &&
objParams.RightBorder + GetStep() >= FieldWidth &&
objParams.DownBorder <= FieldHeight &&
objParams.DownBorder + GetStep() >= FieldHeight;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = FieldWidth - objParams.RightBorder;
if (Math.Abs(diffX) > GetStep())
{
MoveRight();
}
var diffY = FieldHeight - objParams.DownBorder;
if (Math.Abs(diffY) > GetStep())
{
MoveDown();
}
}
}
}

View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.MovementStrategy
{
// Стратегия перемещения объекта в центр экрана
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.MovementStrategy
{
// Параметры-координаты объекта
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
/// <summary>
/// Левая граница
/// </summary>
public int LeftBorder => _x;
/// <summary>
/// Верхняя граница
/// </summary>
public int TopBorder => _y;
/// <summary>
/// Правая граница
/// </summary>
public int RightBorder => _x + _width;
/// <summary>
/// Нижняя граница
/// </summary>
public int DownBorder => _y + _height;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleHorizontal => _x + _width / 2;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleVertical => _y + _height / 2;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.MovementStrategy
{
public enum Status
{
NotInit,
InProgress,
Finish
}
}

View File

@ -0,0 +1,17 @@
namespace ProjectBoat_bae
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormBoat());
}
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae
{
public class ProjectBoat_bae
{
public int Speed { get; private set; }
public double Weight { get; private set; }
// Основной цвет
public Color BodyColor { get; private set; }
// Дополнительный цвет (для опциональных элементов)
public Color AdditionalColor { get; private set; }
public bool body { get; private set; }
public bool Wing { get; private set; }
public bool SportLine { get; private set; }
public double Step => (double)Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса
/// </summary>
/// <param name="speed"
/// <param name="weight"
/// <param name="bodyColor"
/// <param name="additionalColor"
/// <param name="bodyKit"
/// <param name="wing"
/// <param name="sportLine"
//объект
public void Init(int speed, double weight, Color bodyColor, Color
additionalColor, bool bodyKit, bool wing, bool sportLine)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
body = bodyKit;
Wing = wing;
SportLine = sportLine;
}
}
}

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectBoat_bae.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectBoat_bae.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "laba3(base)", "laba3(base)\laba3(base).csproj", "{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DBC78A3D-9D37-411B-8DAD-A904CC5BF8E0}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,39 @@
namespace laba3_base_
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -0,0 +1,10 @@
namespace laba3_base_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace laba3_base_.Generics
{
internal class CarsGenericCollection<T, U>
where T : DrawningPlane
where U : IMoveableObject
{
/// <summary>
/// Ширина окна прорисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна прорисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 175;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 80;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetGeneric<T> _collection;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
public PlanesGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static bool operator +(PlanesGenericCollection<T, U> collect, T?
obj)
{
if (obj == null)
{
return false;
}
return collect?._collection.Insert(obj) ?? false;
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static T? operator -(PlanesGenericCollection<T, U> collect, int
pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
}
return obj;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public U? GetU(int pos)
{
return (U?)_collection.Get(pos)?.GetMoveableObject;
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowCars()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{//линия рамзетки места
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>
/// Метод прорисовки объектов
/// </summary>
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
for (int i = 0; i < _collection.Count; i++)
{
// TODO получение объекта
// TODO установка позиции
// TODO прорисовка объекта
}
}
}
}

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace laba3_base_.Generics
{
internal class SetGeneric<T>
where T : class
{
// Массив объектов, которые храним
private readonly T?[] _places;
// Количество объектов в массиве
public int Count => _places.Length;
// Конструктор
public SetGeneric(int count)
{
_places = new T?[count];
}
// Добавление объекта в набор
public bool Insert(T car)
{
try
{
for (int i = _places.Length - 1; i > 0; i--)
{
_places[i] = _places[i - 1];
}
_places[0] = car;
return true;
}
catch
{
return false;
}
}
// Добавление объекта в набор на конкретную позицию
public bool Insert(T car, int position)
{
if (position < 0 || position >= _places.Count() || car == null)
{
return false;
}
if (_places[position] == null)
{
return false;
}
int positionNull = Array.FindIndex(_places, position, x => x == null);
if (positionNull == -1)
return false;
for (int i = positionNull; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = car;
return true;
}
// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if (position < 0 || position >= _places.Count())
return false;
_places[position] = null;
return true;
}
// Получение объекта из набора по позиции
public T? Get(int position)
{
if (position < 0 || position >= _places.Count())
return null;
return _places[position];
}
}
}

View File

@ -0,0 +1,17 @@
namespace laba3_base_
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>laba3_base_</RootNamespace>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>