From 4b4f3eed79c5a9ff6c3e929287a57c1ab84aba93 Mon Sep 17 00:00:00 2001 From: VanyaAlekseev Date: Sat, 21 Oct 2023 15:06:49 +0400 Subject: [PATCH] SemesterFirstLabThirdBomberBase --- ProjectBomber/ProjectBomber/DrawningBomber.cs | 6 + ProjectBomber/ProjectBomber/Form1.Designer.cs | 13 ++ ProjectBomber/ProjectBomber/Form1.cs | 44 ++++- .../FormPlaneCollection.Designer.cs | 124 ++++++++++++++ .../ProjectBomber/FormPlaneCollection.cs | 89 ++++++++++ .../ProjectBomber/FormPlaneCollection.resx | 120 ++++++++++++++ .../ProjectBomber/PlanesGenericCollection.cs | 156 ++++++++++++++++++ ProjectBomber/ProjectBomber/Program.cs | 2 +- .../ProjectBomber/ProjectBomber.csproj | 38 +++++ ProjectBomber/ProjectBomber/SetGeneric.cs | 123 ++++++++++++++ 10 files changed, 708 insertions(+), 7 deletions(-) create mode 100644 ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs create mode 100644 ProjectBomber/ProjectBomber/FormPlaneCollection.cs create mode 100644 ProjectBomber/ProjectBomber/FormPlaneCollection.resx create mode 100644 ProjectBomber/ProjectBomber/PlanesGenericCollection.cs create mode 100644 ProjectBomber/ProjectBomber/SetGeneric.cs diff --git a/ProjectBomber/ProjectBomber/DrawningBomber.cs b/ProjectBomber/ProjectBomber/DrawningBomber.cs index 5594cbc..3cdf655 100644 --- a/ProjectBomber/ProjectBomber/DrawningBomber.cs +++ b/ProjectBomber/ProjectBomber/DrawningBomber.cs @@ -1,4 +1,5 @@ using ProjectBomber.Entities; +using ProjectBomber.MovementStrategy; using System; using System.Collections.Generic; using System.Drawing; @@ -207,6 +208,11 @@ namespace ProjectBomber.DrawningObjects break; } } + /// + /// Получение объекта IMoveableObject из объекта DrawningCar + /// + public IMoveableObject GetMoveableObject => new + DrawningObjectBomber(this); public virtual void DrawTransport(Graphics g) { if (EntityBomber == null) diff --git a/ProjectBomber/ProjectBomber/Form1.Designer.cs b/ProjectBomber/ProjectBomber/Form1.Designer.cs index 7ac8ffd..4dcd573 100644 --- a/ProjectBomber/ProjectBomber/Form1.Designer.cs +++ b/ProjectBomber/ProjectBomber/Form1.Designer.cs @@ -38,6 +38,7 @@ this.comboBox1Strategy = new System.Windows.Forms.ComboBox(); this.ButtonCreatePlane = new System.Windows.Forms.Button(); this.ButtonStep = new System.Windows.Forms.Button(); + this.ButtonSelectPlane = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBomber)).BeginInit(); this.SuspendLayout(); // @@ -142,10 +143,21 @@ this.ButtonStep.UseVisualStyleBackColor = true; this.ButtonStep.Click += new System.EventHandler(this.ButtonStep_Click); // + // ButtonSelectPlane + // + this.ButtonSelectPlane.Location = new System.Drawing.Point(295, 421); + this.ButtonSelectPlane.Name = "ButtonSelectPlane"; + this.ButtonSelectPlane.Size = new System.Drawing.Size(101, 28); + this.ButtonSelectPlane.TabIndex = 11; + this.ButtonSelectPlane.Text = "Выбрать"; + this.ButtonSelectPlane.UseVisualStyleBackColor = true; + this.ButtonSelectPlane.Click += new System.EventHandler(this.ButtonSelectPlane_Click); + // // FormBomber // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; this.ClientSize = new System.Drawing.Size(884, 461); + this.Controls.Add(this.ButtonSelectPlane); this.Controls.Add(this.ButtonStep); this.Controls.Add(this.ButtonCreatePlane); this.Controls.Add(this.comboBox1Strategy); @@ -175,6 +187,7 @@ private System.Windows.Forms.ComboBox comboBox1Strategy; private System.Windows.Forms.Button ButtonCreatePlane; private System.Windows.Forms.Button ButtonStep; + private System.Windows.Forms.Button ButtonSelectPlane; } } diff --git a/ProjectBomber/ProjectBomber/Form1.cs b/ProjectBomber/ProjectBomber/Form1.cs index fedb957..736e6a9 100644 --- a/ProjectBomber/ProjectBomber/Form1.cs +++ b/ProjectBomber/ProjectBomber/Form1.cs @@ -22,9 +22,15 @@ namespace ProjectBomber /// Стратегии перемещения /// private AbstractStrategy _abstractStrategy; + /// + /// Выбранный автомобиль + /// + public DrawningBomber SelectedBomber { get; private set; } public FormBomber() { InitializeComponent(); + _abstractStrategy = null; + SelectedBomber = null; } private void Draw() { @@ -45,11 +51,22 @@ namespace ProjectBomber private void ButtonCreateBomber_Click(object sender, EventArgs e) { Random random = new Random(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + Color dopColor = Color.FromArgb(random.Next(0, 256), + random.Next(0, 256), random.Next(0, 256)); + //выбор основного цвета и дополнительного + ColorDialog colorDialog = new ColorDialog(); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + color = colorDialog.Color; + if (colorDialog.ShowDialog() == DialogResult.OK) + { + dopColor = colorDialog.Color; + } + } _drawningBomber = new DrawningBomberAdvanced(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)), Convert.ToBoolean(random.Next(0, 2)), - pictureBoxBomber.Width, pictureBoxBomber.Height); + color, dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), + Convert.ToBoolean(random.Next(0, 2)), pictureBoxBomber.Width, pictureBoxBomber.Height); _drawningBomber.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } @@ -61,8 +78,13 @@ namespace ProjectBomber private void ButtonCreatePlane_Click(object sender, EventArgs e) { Random random = new Random(); - _drawningBomber = new DrawningBomber(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), - random.Next(0, 256)), pictureBoxBomber.Width, pictureBoxBomber.Height); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog colorDialog = new ColorDialog(); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + color = colorDialog.Color; + } + _drawningBomber = new DrawningBomber(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxBomber.Width, pictureBoxBomber.Height); _drawningBomber.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } @@ -132,5 +154,15 @@ namespace ProjectBomber _abstractStrategy = null; } } + /// + /// Выбор самолета + /// + /// + /// + private void ButtonSelectPlane_Click(object sender, EventArgs e) + { + SelectedBomber = _drawningBomber; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs b/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs new file mode 100644 index 0000000..35c32ef --- /dev/null +++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.Designer.cs @@ -0,0 +1,124 @@ +namespace ProjectBomber +{ + partial class FormPlaneCollection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.ButtonRefreshCollection = new System.Windows.Forms.Button(); + this.ButtonRemovePlane = new System.Windows.Forms.Button(); + this.maskedTextBoxNumber = new System.Windows.Forms.TextBox(); + this.ButtonAddPlane = new System.Windows.Forms.Button(); + this.pictureBoxCollection = new System.Windows.Forms.PictureBox(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.ButtonRefreshCollection); + this.groupBox1.Controls.Add(this.ButtonRemovePlane); + this.groupBox1.Controls.Add(this.maskedTextBoxNumber); + this.groupBox1.Controls.Add(this.ButtonAddPlane); + this.groupBox1.Location = new System.Drawing.Point(586, 2); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(216, 453); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Инструменты"; + // + // ButtonRefreshCollection + // + this.ButtonRefreshCollection.Location = new System.Drawing.Point(17, 237); + this.ButtonRefreshCollection.Name = "ButtonRefreshCollection"; + this.ButtonRefreshCollection.Size = new System.Drawing.Size(178, 41); + this.ButtonRefreshCollection.TabIndex = 3; + this.ButtonRefreshCollection.Text = "Обновить коллекцию"; + this.ButtonRefreshCollection.UseVisualStyleBackColor = true; + this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click); + // + // ButtonRemovePlane + // + this.ButtonRemovePlane.Location = new System.Drawing.Point(17, 136); + this.ButtonRemovePlane.Name = "ButtonRemovePlane"; + this.ButtonRemovePlane.Size = new System.Drawing.Size(179, 41); + this.ButtonRemovePlane.TabIndex = 2; + this.ButtonRemovePlane.Text = "Удалить автомобиль"; + this.ButtonRemovePlane.UseVisualStyleBackColor = true; + this.ButtonRemovePlane.Click += new System.EventHandler(this.ButtonRemovePlane_Click); + // + // maskedTextBoxNumber + // + this.maskedTextBoxNumber.Location = new System.Drawing.Point(17, 99); + this.maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + this.maskedTextBoxNumber.Size = new System.Drawing.Size(180, 20); + this.maskedTextBoxNumber.TabIndex = 1; + // + // ButtonAddPlane + // + this.ButtonAddPlane.Location = new System.Drawing.Point(17, 36); + this.ButtonAddPlane.Name = "ButtonAddPlane"; + this.ButtonAddPlane.Size = new System.Drawing.Size(185, 40); + this.ButtonAddPlane.TabIndex = 0; + this.ButtonAddPlane.Text = "Добавить самолет"; + this.ButtonAddPlane.UseVisualStyleBackColor = true; + this.ButtonAddPlane.Click += new System.EventHandler(this.ButtonAddPlane_Click); + // + // pictureBoxCollection + // + this.pictureBoxCollection.Location = new System.Drawing.Point(-2, 2); + this.pictureBoxCollection.Name = "pictureBoxCollection"; + this.pictureBoxCollection.Size = new System.Drawing.Size(600, 452); + this.pictureBoxCollection.TabIndex = 1; + this.pictureBoxCollection.TabStop = false; + // + // FormPlaneCollection + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.pictureBoxCollection); + this.Controls.Add(this.groupBox1); + this.Name = "FormPlaneCollection"; + this.Text = "Набор самолетов"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button ButtonRefreshCollection; + private System.Windows.Forms.Button ButtonRemovePlane; + private System.Windows.Forms.TextBox maskedTextBoxNumber; + private System.Windows.Forms.Button ButtonAddPlane; + private System.Windows.Forms.PictureBox pictureBoxCollection; + } +} \ No newline at end of file diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.cs b/ProjectBomber/ProjectBomber/FormPlaneCollection.cs new file mode 100644 index 0000000..f10fafc --- /dev/null +++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.cs @@ -0,0 +1,89 @@ +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 ProjectBomber.MovementStrategy; +using ProjectBomber.Generics; +using ProjectBomber.DrawningObjects; + +namespace ProjectBomber +{ + /// + /// Форма для работы с набором объектов класса DrawningCar + /// + public partial class FormPlaneCollection : Form + { + /// + /// Набор объектов + /// + private readonly PlanesGenericCollection _planes; + /// + /// Конструктор + /// + public FormPlaneCollection() + { + InitializeComponent(); + _planes = new PlanesGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); + } + /// + /// Добавление объекта в набор + /// + /// + /// + private void ButtonAddPlane_Click(object sender, EventArgs e) + { + FormBomber form = new FormBomber(); + if (form.ShowDialog() == DialogResult.OK) + { + if (_planes + form.SelectedBomber != 1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = _planes.ShowPlanes(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + /// + /// Удаление объекта из набора + /// + /// + /// + private void ButtonRemovePlane_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить объект?", "Удаление", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxNumber.Text); + if (_planes - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = _planes.ShowPlanes(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + /// + /// Обновление рисунка по набору + /// + /// + /// + private void ButtonRefreshCollection_Click(object sender, EventArgs e) + { + pictureBoxCollection.Image = _planes.ShowPlanes(); + } + } +} diff --git a/ProjectBomber/ProjectBomber/FormPlaneCollection.resx b/ProjectBomber/ProjectBomber/FormPlaneCollection.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ProjectBomber/ProjectBomber/FormPlaneCollection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectBomber/ProjectBomber/PlanesGenericCollection.cs b/ProjectBomber/ProjectBomber/PlanesGenericCollection.cs new file mode 100644 index 0000000..a86241d --- /dev/null +++ b/ProjectBomber/ProjectBomber/PlanesGenericCollection.cs @@ -0,0 +1,156 @@ +using ProjectBomber.MovementStrategy; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectBomber.DrawningObjects; + +namespace ProjectBomber.Generics +{ + /// + /// Параметризованный класс для набора объектов DrawningBomber + /// + /// + /// + internal class PlanesGenericCollection + where T : DrawningBomber + where U : IMoveableObject + { + /// + /// Ширина окна прорисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна прорисовки + /// + private readonly int _pictureHeight; + /// + /// Размер занимаемого объектом места (ширина) + /// + private readonly int _placeSizeWidth = 200; + /// + /// Размер занимаемого объектом места (высота) + /// + private readonly int _placeSizeHeight = 90; + /// + /// Набор объектов + /// + private readonly SetGeneric _collection; + /// + /// Конструктор + /// + /// + /// + public PlanesGenericCollection(int picWidth, int picHeight) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _collection = new SetGeneric(width * height); + } + /// + /// Перегрузка оператора сложения + /// + /// + /// + /// + public static int? operator +(PlanesGenericCollection collect, T + obj) + { + if (obj == null) + { + return -1; + } + return collect?._collection.Insert(obj); + } + /// + /// Перегрузка оператора вычитания + /// + /// + /// + /// + public static bool operator -(PlanesGenericCollection collect, int + pos) + { + T obj = collect._collection.Get(pos); + if (obj == null) + { + return false; + } + return collect._collection.Remove(pos); + } + /// + /// Получение объекта IMoveableObject + /// + /// + /// + public U GetU(int pos) + { + return (U)_collection.Get(pos)?.GetMoveableObject; + } + /// + /// Вывод всего набора объектов + /// + /// + public Bitmap ShowPlanes() + { + Bitmap bmp = new Bitmap(_pictureWidth, _pictureHeight); + Graphics gr = Graphics.FromImage(bmp); + DrawBackground(gr); + DrawObjects(gr); + return bmp; + } + /// + /// Метод отрисовки фона + /// + /// + private void DrawBackground(Graphics g) + { + Pen pen = new Pen(Color.Black, 3); + int numColumns = _pictureWidth / _placeSizeWidth; + int numRows = _pictureHeight / _placeSizeHeight; + + for (int i = 0; i <= numColumns; i++) + { + for (int j = 0; j <= numRows; ++j) + { + // Линии разметки места + int x = i * _placeSizeWidth; + int y = j * _placeSizeHeight; + g.DrawLine(pen, x, y, x + _placeSizeWidth / 2, y); + } + + g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, numRows * _placeSizeHeight); + } + } + + /// + /// Метод прорисовки объектов + /// + /// + private void DrawObjects(Graphics g) + { + int numColumns = _pictureWidth / _placeSizeWidth; + int numRows = _pictureHeight / _placeSizeHeight; + + for (int i = 0; i < _collection.Count; i++) + { + DrawningBomber plane = _collection.Get(i); + if (plane != null) + { + // Вычисляем позицию объекта + int row = i / numColumns; // Номер строки + int column = numColumns - 1 - (i % numColumns); // Номер столбца, инвертируем для движения справа налево + int x = column * _placeSizeWidth; + int y = row * _placeSizeHeight; + + plane.SetPosition(x, y); + plane.DrawTransport(g); + } + } + } + } +} diff --git a/ProjectBomber/ProjectBomber/Program.cs b/ProjectBomber/ProjectBomber/Program.cs index 53184ea..3093df6 100644 --- a/ProjectBomber/ProjectBomber/Program.cs +++ b/ProjectBomber/ProjectBomber/Program.cs @@ -16,7 +16,7 @@ namespace ProjectBomber { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormBomber()); + Application.Run(new FormPlaneCollection()); } } } diff --git a/ProjectBomber/ProjectBomber/ProjectBomber.csproj b/ProjectBomber/ProjectBomber/ProjectBomber.csproj index 16b6ff0..12e44ab 100644 --- a/ProjectBomber/ProjectBomber/ProjectBomber.csproj +++ b/ProjectBomber/ProjectBomber/ProjectBomber.csproj @@ -12,6 +12,21 @@ 512 true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -59,16 +74,27 @@ Form1.cs + + Form + + + FormPlaneCollection.cs + + + Form1.cs + + FormPlaneCollection.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -91,5 +117,17 @@ + + + False + Microsoft .NET Framework 4.7.2 %28x86 и x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/ProjectBomber/ProjectBomber/SetGeneric.cs b/ProjectBomber/ProjectBomber/SetGeneric.cs new file mode 100644 index 0000000..dd37436 --- /dev/null +++ b/ProjectBomber/ProjectBomber/SetGeneric.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectBomber.Generics +{ + /// + /// Параметризованный набор объектов + /// + /// + internal class SetGeneric + where T : class + { + /// + /// Массив объектов, которые храним + /// + private readonly T[] _places; + /// + /// Количество объектов в массиве + /// + public int Count => _places.Length; + /// + /// Конструктор + /// + /// + public SetGeneric(int count) + { + _places = new T[count]; + } + /// + /// Добавление объекта в набор + /// + /// Добавляемый самолет + /// + public int Insert(T plane) + { + int index = -1; + for (int i = 0; i < _places.Length; i++) + { + if (_places[i] == null) + { + index = i; break; + } + } + if (index < 0) + { + return -1; + } + for (int i = index; i > 0; i--) + { + _places[i] = _places[i - 1]; + } + _places[0] = plane; + return 0; + } + /// + /// Добавление объекта в набор на конкретную позицию + /// + /// Добавляемый автомобиль + /// Позиция + /// + public int Insert(T plane, int position) + { + ///Проверка позиции + if (position < 0 || position >= _places.Length) + return -1; + /// Проверка, что элемент массива по этой позиции пустой, если нет, то проверка, + /// что после вставляемого элемента в массиве есть пустой элемент + if (_places[position] != null) + { + /// Проверка, что после вставляемого элемента в массиве есть пустой элемент + int firstEmptyPosition = -1; + for (int i = position + 1; i < _places.Length; i++) + { + if (_places[i] == null) + { + firstEmptyPosition = i; + break; + } + } + /// Нет пустой позиции после вставляемой + if (firstEmptyPosition == -1) + return -1; + /// Сдвиг всех объектов, находящихся справа от позиции, до первого пустого элемента + for (int i = firstEmptyPosition; i > position; i--) + { + _places[i] = _places[i - 1]; + } + } + /// Вставка по позиции + _places[position] = plane; + return 0; + } + /// + /// Удаление объекта из набора с конкретной позиции + /// + /// + /// + public bool Remove(int position) + { + /// Проверка позиции + if (position < 0 || position >= _places.Length) + return false; + /// Удаление объекта из массива, присвоив элементу массива значение null + _places[position] = null; + return true; + } + /// + /// Получение объекта из набора по позиции + /// + /// + /// + public T Get(int position) + { + // Проверка позиции + if (position < 0 || position >= _places.Length) + return null; + return _places[position]; + } + } +} -- 2.25.1