Вроде как доделанная лаба
This commit is contained in:
parent
6c938430b0
commit
9a7af194fe
241
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
241
Airbus/Airbus/FormMapWithSetPlanes.Designer.cs
generated
@ -29,17 +29,17 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonAddPlane = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonRemovePlane = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonRemovePlane = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddPlane = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -57,123 +57,150 @@
|
||||
this.groupBox1.Controls.Add(this.buttonAddPlane);
|
||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(600, 0);
|
||||
this.groupBox1.Location = new System.Drawing.Point(685, 0);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 450);
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.groupBox1.Size = new System.Drawing.Size(229, 600);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Name = "pictureBox1";
|
||||
this.pictureBox.Size = new System.Drawing.Size(600, 450);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 22);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(171, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
//
|
||||
// buttonAddPlane
|
||||
//
|
||||
this.buttonAddPlane.Location = new System.Drawing.Point(17, 64);
|
||||
this.buttonAddPlane.Name = "buttonAddPlane";
|
||||
this.buttonAddPlane.Size = new System.Drawing.Size(171, 31);
|
||||
this.buttonAddPlane.TabIndex = 1;
|
||||
this.buttonAddPlane.Text = "Добавить самолёт";
|
||||
this.buttonAddPlane.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 126);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(171, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 2;
|
||||
//
|
||||
// buttonRemovePlane
|
||||
//
|
||||
this.buttonRemovePlane.Location = new System.Drawing.Point(17, 169);
|
||||
this.buttonRemovePlane.Name = "buttonRemovePlane";
|
||||
this.buttonRemovePlane.Size = new System.Drawing.Size(171, 31);
|
||||
this.buttonRemovePlane.TabIndex = 3;
|
||||
this.buttonRemovePlane.Text = "Удалить самолёт";
|
||||
this.buttonRemovePlane.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(17, 259);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(171, 34);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(17, 308);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(171, 31);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(92, 370);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(92, 406);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 7;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(128, 406);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 8;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(56, 406);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(64, 541);
|
||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonLeft.TabIndex = 9;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(146, 541);
|
||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonRight.TabIndex = 8;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(105, 541);
|
||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonDown.TabIndex = 7;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(105, 493);
|
||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(19, 411);
|
||||
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(195, 41);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.buttonShowOnMap_Click_1);
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(19, 345);
|
||||
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(195, 45);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonShowStorage.Click += new System.EventHandler(this.buttonShowStorage_Click_1);
|
||||
//
|
||||
// buttonRemovePlane
|
||||
//
|
||||
this.buttonRemovePlane.Location = new System.Drawing.Point(19, 225);
|
||||
this.buttonRemovePlane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonRemovePlane.Name = "buttonRemovePlane";
|
||||
this.buttonRemovePlane.Size = new System.Drawing.Size(195, 41);
|
||||
this.buttonRemovePlane.TabIndex = 3;
|
||||
this.buttonRemovePlane.Text = "Удалить самолёт";
|
||||
this.buttonRemovePlane.UseVisualStyleBackColor = true;
|
||||
this.buttonRemovePlane.Click += new System.EventHandler(this.buttonRemovePlane_Click_1);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 168);
|
||||
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(195, 27);
|
||||
this.maskedTextBoxPosition.TabIndex = 2;
|
||||
//
|
||||
// buttonAddPlane
|
||||
//
|
||||
this.buttonAddPlane.Location = new System.Drawing.Point(19, 85);
|
||||
this.buttonAddPlane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonAddPlane.Name = "buttonAddPlane";
|
||||
this.buttonAddPlane.Size = new System.Drawing.Size(195, 41);
|
||||
this.buttonAddPlane.TabIndex = 1;
|
||||
this.buttonAddPlane.Text = "Добавить самолёт";
|
||||
this.buttonAddPlane.UseVisualStyleBackColor = true;
|
||||
this.buttonAddPlane.Click += new System.EventHandler(this.buttonAddPlane_Click_1);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Вторая карта"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 29);
|
||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(195, 28);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged_1);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(685, 600);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetPlanes
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(914, 600);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormMapWithSetPlanes";
|
||||
this.Text = "FormMapWithSetPlanes";
|
||||
this.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
|
@ -29,7 +29,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void comboBoxSelectorMap_SelectedIndexChanged_1(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
@ -37,6 +37,10 @@ namespace Airbus
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Вторая карта":
|
||||
map = new MyMap();
|
||||
break;
|
||||
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
@ -53,7 +57,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddPlane_Click(object sender, EventArgs e)
|
||||
private void buttonAddPlane_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapPlanesCollectionGeneric == null)
|
||||
{
|
||||
@ -63,7 +67,7 @@ namespace Airbus
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectPlane plane = new(form.SelectedPlane);
|
||||
if (_mapPlanesCollectionGeneric + plane)
|
||||
if (_mapPlanesCollectionGeneric + plane != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
|
||||
@ -79,7 +83,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemovePlane_Click(object sender, EventArgs e)
|
||||
private void buttonRemovePlane_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
@ -90,7 +94,7 @@ namespace Airbus
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapPlanesCollectionGeneric - pos)
|
||||
if (_mapPlanesCollectionGeneric - pos != -1)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
|
||||
@ -105,7 +109,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
private void buttonShowStorage_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapPlanesCollectionGeneric == null)
|
||||
{
|
||||
@ -118,7 +122,7 @@ namespace Airbus
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
private void buttonShowOnMap_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapPlanesCollectionGeneric == null)
|
||||
{
|
||||
@ -157,5 +161,7 @@ namespace Airbus
|
||||
}
|
||||
pictureBox.Image = _mapPlanesCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace Airbus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="planes"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(MapWithSetPlanesGeneric<T, U> map, T planes)
|
||||
public static int operator +(MapWithSetPlanesGeneric<T, U> map, T planes)
|
||||
{
|
||||
return map._setPlanes.Insert(planes);
|
||||
}
|
||||
@ -65,7 +65,7 @@ namespace Airbus
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(MapWithSetPlanesGeneric<T, U> map, int position)
|
||||
public static int operator -(MapWithSetPlanesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setPlanes.Remove(position);
|
||||
}
|
||||
@ -162,12 +162,19 @@ namespace Airbus
|
||||
/// <param name="g"></param>
|
||||
private void DrawPlanes(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
for (int i = 0; i < _setPlanes.Count; i++)
|
||||
{
|
||||
// TODO установка позиции
|
||||
if(_setPlanes.Get(i) != null)
|
||||
{
|
||||
_setPlanes.Get(i).SetObject(i % width * _placeSizeWidth, (height - 1 - i / width) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||
_setPlanes.Get(i)?.DrawningObject(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,39 +28,70 @@ namespace Airbus
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="car">Добавляемый автомобиль</param>
|
||||
/// <param name="car">Добавляемый самолёт</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T plane)
|
||||
public int Insert(T plane)
|
||||
{
|
||||
// TODO вставка в начало набора
|
||||
return true;
|
||||
return Insert(plane, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="plane">Добавляемый автомобиль</param>
|
||||
/// <param name="plane">Добавляемый самолёт</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T plane, int position)
|
||||
public int Insert(T plane, int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
||||
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
||||
// TODO вставка по позиции
|
||||
|
||||
if(_places[position] == null)
|
||||
{
|
||||
_places[position] = plane;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFree = false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
isFree = true;
|
||||
}
|
||||
}
|
||||
if (isFree)
|
||||
{
|
||||
for (var i = _places.Length - 1; i != 0; --i) _places[i] = _places[i - 1];
|
||||
_places[position] = plane;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
public int Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из массива, присовив элементу массива значение null
|
||||
return true;
|
||||
if(position < 0 || position >= Count || _places[position] == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
_places[position] = null;
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
@ -70,6 +101,10 @@ namespace Airbus
|
||||
public T Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user