вроде готовая лаба 4

This commit is contained in:
a.puchkina 2023-11-06 20:19:29 +04:00
parent 5ac338e378
commit 3e922ab4dd
5 changed files with 337 additions and 81 deletions

View File

@ -56,13 +56,13 @@ namespace AirplaneWithRadar.Generics
/// <param name="collect"></param> /// <param name="collect"></param>
/// <param name="obj"></param> /// <param name="obj"></param>
/// <returns></returns> /// <returns></returns>
public static int operator +(AirplanesGenericCollection<T, U> collect, T? obj) public static bool operator +(AirplanesGenericCollection<T, U> collect, T? obj)
{ {
if (obj == null) if (obj == null)
{ {
return -1; return false;
} }
return collect?._collection.Insert(obj) ?? -1; return (bool)collect?._collection.Insert(obj);
} }
/// <summary> /// <summary>
/// Перегрузка оператора вычитания /// Перегрузка оператора вычитания
@ -73,7 +73,7 @@ namespace AirplaneWithRadar.Generics
public static bool operator -(AirplanesGenericCollection<T, U> collect, int public static bool operator -(AirplanesGenericCollection<T, U> collect, int
pos) pos)
{ {
T? obj = collect._collection.Get(pos); T? obj = collect._collection[pos];
if (obj != null) if (obj != null)
{ {
collect._collection.Remove(pos); collect._collection.Remove(pos);
@ -87,7 +87,7 @@ namespace AirplaneWithRadar.Generics
/// <returns></returns> /// <returns></returns>
public U? GetU(int pos) public U? GetU(int pos)
{ {
return (U?)_collection.Get(pos)?.GetMoveableObject; return (U?)_collection[pos]?.GetMoveableObject;
} }
/// <summary> /// <summary>
/// Вывод всего набора объектов /// Вывод всего набора объектов
@ -126,25 +126,18 @@ namespace AirplaneWithRadar.Generics
/// <param name="g"></param> /// <param name="g"></param>
private void DrawObjects(Graphics g) private void DrawObjects(Graphics g)
{ {
T? t; int i = 0;
int Rows = _pictureWidth / _placeSizeWidth; foreach (var airplane in _collection.GetAirplanes())
int diff = 1;
int currWidth = 0;
for (int i = 0; i < _collection.Count; i++)
{ {
currWidth++; if (airplane!= null)
if (currWidth > Rows)
{ {
diff++; airplane.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
currWidth = 1; if (airplane is DrawningAirplaneWithRadar)
} (airplane as DrawningAirplaneWithRadar).DrawTransport(g);
t = _collection.Get(i); else airplane.DrawTransport(g);
if (t != null) airplane.DrawTransport(g);
{
t.SetPosition((Rows - 1 - (i % Rows)) * _placeSizeWidth, i / Rows * _placeSizeHeight);
t.DrawTransport(g);
} }
i++;
} }
} }
} }

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AirplaneWithRadar.DrawningObjects;
using AirplaneWithRadar.MovementStrategy;
namespace AirplaneWithRadar.Generics
{
/// <summary>
/// Класс для хранения коллекции
/// </summary>
internal class AirplanesGenericStorage
{
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, AirplanesGenericCollection<DrawningAirplane,
DrawningObjectAirplane>> _airplaneStorages;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
public List<string> Keys => _airplaneStorages.Keys.ToList();
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public AirplanesGenericStorage(int pictureWidth, int pictureHeight)
{
_airplaneStorages = new Dictionary<string,
AirplanesGenericCollection<DrawningAirplane, DrawningObjectAirplane>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление набора
/// </summary>
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
if (_airplaneStorages.ContainsKey(name))
return;
_airplaneStorages[name] = new AirplanesGenericCollection<DrawningAirplane,
DrawningObjectAirplane>(_pictureWidth, _pictureHeight);
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="name">Название набора</param>
public void DelSet(string name)
{
if (!_airplaneStorages.ContainsKey(name))
return;
_airplaneStorages.Remove(name);
}
/// <summary>
/// Доступ к набору
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public AirplanesGenericCollection<DrawningAirplane, DrawningObjectAirplane>?
this[string ind]
{
get
{
if (_airplaneStorages.ContainsKey(ind))
return _airplaneStorages[ind];
return null;
}
}
}
}

View File

@ -29,43 +29,102 @@
private void InitializeComponent() private void InitializeComponent()
{ {
groupBoxInstruments = new GroupBox(); groupBoxInstruments = new GroupBox();
groupBoxSets = new GroupBox();
buttonDeleteSet = new Button();
listBoxStorages = new ListBox();
buttonAddInSet = new Button();
textBoxStorageName = new TextBox();
maskedTextBoxNumber = new MaskedTextBox(); maskedTextBoxNumber = new MaskedTextBox();
buttonUpdate = new Button(); buttonUpdate = new Button();
buttonAdd = new Button(); buttonAdd = new Button();
buttonDelete = new Button(); buttonDelete = new Button();
pictureBoxCollection = new PictureBox(); pictureBoxCollection = new PictureBox();
groupBoxInstruments.SuspendLayout(); groupBoxInstruments.SuspendLayout();
groupBoxSets.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// groupBoxInstruments // groupBoxInstruments
// //
groupBoxInstruments.Controls.Add(groupBoxSets);
groupBoxInstruments.Controls.Add(maskedTextBoxNumber); groupBoxInstruments.Controls.Add(maskedTextBoxNumber);
groupBoxInstruments.Controls.Add(buttonUpdate); groupBoxInstruments.Controls.Add(buttonUpdate);
groupBoxInstruments.Controls.Add(buttonAdd); groupBoxInstruments.Controls.Add(buttonAdd);
groupBoxInstruments.Controls.Add(buttonDelete); groupBoxInstruments.Controls.Add(buttonDelete);
groupBoxInstruments.Dock = DockStyle.Right; groupBoxInstruments.Dock = DockStyle.Right;
groupBoxInstruments.Location = new Point(699, 0); groupBoxInstruments.Location = new Point(707, 0);
groupBoxInstruments.Margin = new Padding(2, 2, 2, 2); groupBoxInstruments.Margin = new Padding(2);
groupBoxInstruments.Name = "groupBoxInstruments"; groupBoxInstruments.Name = "groupBoxInstruments";
groupBoxInstruments.Padding = new Padding(2, 2, 2, 2); groupBoxInstruments.Padding = new Padding(2);
groupBoxInstruments.Size = new Size(170, 497); groupBoxInstruments.Size = new Size(214, 570);
groupBoxInstruments.TabIndex = 5; groupBoxInstruments.TabIndex = 5;
groupBoxInstruments.TabStop = false; groupBoxInstruments.TabStop = false;
groupBoxInstruments.Text = "Инструменты"; groupBoxInstruments.Text = "Инструменты";
// //
// groupBoxSets
//
groupBoxSets.Controls.Add(buttonDeleteSet);
groupBoxSets.Controls.Add(listBoxStorages);
groupBoxSets.Controls.Add(buttonAddInSet);
groupBoxSets.Controls.Add(textBoxStorageName);
groupBoxSets.Location = new Point(14, 33);
groupBoxSets.Name = "groupBoxSets";
groupBoxSets.Size = new Size(182, 313);
groupBoxSets.TabIndex = 6;
groupBoxSets.TabStop = false;
groupBoxSets.Text = "Наборы";
//
// buttonDeleteSet
//
buttonDeleteSet.Location = new Point(9, 223);
buttonDeleteSet.Margin = new Padding(2);
buttonDeleteSet.Name = "buttonDeleteSet";
buttonDeleteSet.Size = new Size(166, 30);
buttonDeleteSet.TabIndex = 9;
buttonDeleteSet.Text = "Удалить набор";
buttonDeleteSet.UseVisualStyleBackColor = true;
buttonDeleteSet.Click += buttonDeleteSet_Click;
//
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(14, 111);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(152, 84);
listBoxStorages.TabIndex = 8;
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
//
// buttonAddInSet
//
buttonAddInSet.Location = new Point(9, 65);
buttonAddInSet.Margin = new Padding(2);
buttonAddInSet.Name = "buttonAddInSet";
buttonAddInSet.Size = new Size(166, 30);
buttonAddInSet.TabIndex = 7;
buttonAddInSet.Text = "Добавить в набор";
buttonAddInSet.UseVisualStyleBackColor = true;
buttonAddInSet.Click += buttonAddInSet_Click;
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(9, 33);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(162, 27);
textBoxStorageName.TabIndex = 0;
//
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Location = new Point(31, 142); maskedTextBoxNumber.Location = new Point(51, 425);
maskedTextBoxNumber.Margin = new Padding(2, 2, 2, 2); maskedTextBoxNumber.Margin = new Padding(2);
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(119, 27); maskedTextBoxNumber.Size = new Size(119, 27);
maskedTextBoxNumber.TabIndex = 5; maskedTextBoxNumber.TabIndex = 5;
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(18, 247); buttonUpdate.Location = new Point(38, 509);
buttonUpdate.Margin = new Padding(2, 2, 2, 2); buttonUpdate.Margin = new Padding(2);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(142, 50); buttonUpdate.Size = new Size(142, 50);
buttonUpdate.TabIndex = 4; buttonUpdate.TabIndex = 4;
@ -75,10 +134,10 @@
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(18, 53); buttonAdd.Location = new Point(30, 369);
buttonAdd.Margin = new Padding(2, 2, 2, 2); buttonAdd.Margin = new Padding(2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(142, 30); buttonAdd.Size = new Size(166, 30);
buttonAdd.TabIndex = 1; buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить самолет"; buttonAdd.Text = "Добавить самолет";
buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = true;
@ -86,8 +145,8 @@
// //
// buttonDelete // buttonDelete
// //
buttonDelete.Location = new Point(18, 171); buttonDelete.Location = new Point(38, 456);
buttonDelete.Margin = new Padding(2, 2, 2, 2); buttonDelete.Margin = new Padding(2);
buttonDelete.Name = "buttonDelete"; buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(142, 30); buttonDelete.Size = new Size(142, 30);
buttonDelete.TabIndex = 3; buttonDelete.TabIndex = 3;
@ -99,9 +158,9 @@
// //
pictureBoxCollection.Dock = DockStyle.Fill; pictureBoxCollection.Dock = DockStyle.Fill;
pictureBoxCollection.Location = new Point(0, 0); pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Margin = new Padding(2, 2, 2, 2); pictureBoxCollection.Margin = new Padding(2);
pictureBoxCollection.Name = "pictureBoxCollection"; pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(699, 497); pictureBoxCollection.Size = new Size(707, 570);
pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize; pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxCollection.TabIndex = 6; pictureBoxCollection.TabIndex = 6;
pictureBoxCollection.TabStop = false; pictureBoxCollection.TabStop = false;
@ -110,14 +169,16 @@
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(869, 497); ClientSize = new Size(921, 570);
Controls.Add(pictureBoxCollection); Controls.Add(pictureBoxCollection);
Controls.Add(groupBoxInstruments); Controls.Add(groupBoxInstruments);
Margin = new Padding(2, 2, 2, 2); Margin = new Padding(2);
Name = "FormAirplaneCollection"; Name = "FormAirplaneCollection";
Text = "FormAirplaneCollection"; Text = "FormAirplaneCollection";
groupBoxInstruments.ResumeLayout(false); groupBoxInstruments.ResumeLayout(false);
groupBoxInstruments.PerformLayout(); groupBoxInstruments.PerformLayout();
groupBoxSets.ResumeLayout(false);
groupBoxSets.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
@ -130,5 +191,10 @@
private GroupBox groupBoxInstruments; private GroupBox groupBoxInstruments;
private PictureBox pictureBoxCollection; private PictureBox pictureBoxCollection;
private MaskedTextBox maskedTextBoxNumber; private MaskedTextBox maskedTextBoxNumber;
private GroupBox groupBoxSets;
private Button buttonDeleteSet;
private ListBox listBoxStorages;
private Button buttonAddInSet;
private TextBox textBoxStorageName;
} }
} }

View File

@ -21,16 +21,82 @@ namespace AirplaneWithRadar
/// <summary> /// <summary>
/// Набор объектов /// Набор объектов
/// </summary> /// </summary>
private readonly AirplanesGenericCollection<DrawningAirplane, private readonly AirplanesGenericStorage _storage;
DrawningObjectAirplane> _airplanes;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>
public FormAirplaneCollection() public FormAirplaneCollection()
{ {
InitializeComponent(); InitializeComponent();
_airplanes = new AirplanesGenericCollection<DrawningAirplane, _storage = new AirplanesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
DrawningObjectAirplane>(pictureBoxCollection.Width, pictureBoxCollection.Height); }
/// <summary>
/// Заполнение listBoxObjects
/// </summary>
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorages.Items.Add(_storage.Keys[i]);
}
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
>= listBoxStorages.Items.Count))
{
listBoxStorages.SelectedIndex = 0;
}
else if (listBoxStorages.Items.Count > 0 && index > -1 &&
index < listBoxStorages.Items.Count)
{
listBoxStorages.SelectedIndex = index;
}
}
/// <summary>
/// Добавление набора в коллекцию
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddInSet_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
}
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAirplanes();
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonDeleteSet_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить объект { listBoxStorages.SelectedItem}?",
"Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString()
?? string.Empty);
ReloadObjects();
}
} }
/// <summary> /// <summary>
/// Добавление объекта в набор /// Добавление объекта в набор
@ -39,13 +105,23 @@ namespace AirplaneWithRadar
/// <param name="e"></param> /// <param name="e"></param>
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
{
return;
}
AirplaneWithRadarForm form = new(); AirplaneWithRadarForm form = new();
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
if (_airplanes + form.SelectedAirplane != -1) if (obj + form.SelectedAirplane)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _airplanes.ShowAirplanes(); pictureBoxCollection.Image = obj.ShowAirplanes();
} }
else else
{ {
@ -60,21 +136,32 @@ namespace AirplaneWithRadar
/// <param name="e"></param> /// <param name="e"></param>
private void buttonDelete_Click(object sender, EventArgs e) private void buttonDelete_Click(object sender, EventArgs e)
{ {
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{ {
return; return;
} }
int pos = Convert.ToInt32(maskedTextBoxNumber.Text); int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (_airplanes - pos != null) if (obj - pos != null)
{ {
MessageBox.Show("Объект удален"); MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _airplanes.ShowAirplanes(); pictureBoxCollection.Image = obj.ShowAirplanes();
} }
else else
{ {
MessageBox.Show("Не удалось удалить объект"); MessageBox.Show("Не удалось удалить объект");
} }
} }
/// <summary> /// <summary>
/// Обновление рисунка по набору /// Обновление рисунка по набору
@ -83,7 +170,18 @@ namespace AirplaneWithRadar
/// <param name="e"></param> /// <param name="e"></param>
private void buttonUpdate_Click(object sender, EventArgs e) private void buttonUpdate_Click(object sender, EventArgs e)
{ {
pictureBoxCollection.Image = _airplanes.ShowAirplanes(); if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollection.Image = obj.ShowAirplanes();
} }
} }
} }

View File

@ -14,58 +14,51 @@ namespace AirplaneWithRadar.Generics
where T : class where T : class
{ {
/// <summary> /// <summary>
/// Массив объектов, которые храним /// Список объектов, которые храним
/// </summary> /// </summary>
private readonly T?[] _places; private readonly List<T?> _places;
/// <summary> /// <summary>
/// Количество объектов в массиве /// Количество объектов в массиве
/// </summary> /// </summary>
public int Count => _places.Length; public int Count => _places.Count;
/// <summary>
/// Максимальное количество объектов в списке
/// </summary>
private readonly int _maxCount;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>
/// <param name="count"></param> /// <param name="count"></param>
public SetGeneric(int count) public SetGeneric(int count)
{ {
_places = new T?[count]; _maxCount = count;
_places = new List<T?>(count);
} }
/// <summary> /// <summary>
/// Добавление объекта в набор /// Добавление объекта в набор
/// </summary> /// </summary>
/// <param name="car">Добавляемый самолет</param> /// <param name="airplane">Добавляемый самолет</param>
/// <returns></returns> /// <returns></returns>
public int Insert(T airplane) public bool Insert(T airplane)
{ {
return Insert(airplane, 0); if (_places.Count == _maxCount)
{
return false;
}
Insert(airplane, 0);
return true;
} }
/// <summary> /// <summary>
/// Добавление объекта в набор на конкретную позицию /// Добавление объекта в набор на конкретную позицию
/// </summary> /// </summary>
/// <param name="car">Добавляемый автомобиль</param> /// <param name="airplane">Добавляемый самолет</param>
/// <param name="position">Позиция</param> /// <param name="position">Позиция</param>
/// <returns></returns> /// <returns></returns>
public int Insert(T airplane, int position) public bool Insert(T airplane, int position)
{ {
int nullIndex = -1, i; if (!(position >= 0 && position <= Count && _places.Count < _maxCount)) return false;
if (position < 0 || position >= Count) _places.Insert(position, airplane);
{ return true;
return -1;
}
for (i = position; i < Count; i++)
{
if (_places[i] == null)
{
nullIndex = i;
break;
}
}
if (nullIndex < 0) return -1;
for (i = nullIndex; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = airplane;
return position;
} }
/// <summary> /// <summary>
/// Удаление объекта из набора с конкретной позиции /// Удаление объекта из набора с конкретной позиции
@ -75,7 +68,7 @@ namespace AirplaneWithRadar.Generics
public bool Remove(int position) public bool Remove(int position)
{ {
if (position < 0 || position >= Count) return false; if (position < 0 || position >= Count) return false;
_places[position] = null; _places.RemoveAt(position);
return true; return true;
} }
/// <summary> /// <summary>
@ -83,10 +76,34 @@ namespace AirplaneWithRadar.Generics
/// </summary> /// </summary>
/// <param name="position"></param> /// <param name="position"></param>
/// <returns></returns> /// <returns></returns>
public T? Get(int position) public T? this[int position]
{
get
{ {
if (position < 0 || position >= Count) return null; if (position < 0 || position >= Count) return null;
return _places[position]; return _places[position];
} }
set
{
if (!(position >= 0 && position < Count && _places.Count < _maxCount)) return;
_places.Insert(position, value);
return;
}
}
/// <summary>
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetAirplanes(int? maxAirplanes = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxAirplanes.HasValue && i == maxAirplanes.Value)
{
yield break;
}
}
}
} }
} }