diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
index f5c74f8..863cbf7 100644
--- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
+++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
@@ -1,4 +1,5 @@
using ProjectExcavator.Entities;
+using ProjectExcavator.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,6 +14,11 @@ namespace ProjectExcavator.DrawningObjects
/// Класс-сущность
///
public EntityExcavator? EntityExcavator { get; protected set; }
+ ///
+ /// Получение объекта IMoveableObject из объекта DrawningCar
+ ///
+ public IMoveableObject GetMoveableObject => new DrawningObjectExcavator(this);
+
///
/// Ширина окна
///
@@ -169,7 +175,7 @@ namespace ProjectExcavator.DrawningObjects
}
Pen pen = new(Color.Black);
//корпус
- Brush bodyBrush = new SolidBrush(Color.Red);
+ Brush bodyBrush = new SolidBrush(Color.Aqua);
g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 60, 130, 20);
g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 20, 30, 40);
g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 40, 10, 20);
diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
index 6352b5c..cea0cf3 100644
--- a/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.Designer.cs
@@ -37,6 +37,7 @@
comboBoxStrategy = new ComboBox();
buttonCreateExcavatorBodyKits = new Button();
buttonStep = new Button();
+ buttonSelectObject = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit();
SuspendLayout();
//
@@ -44,9 +45,8 @@
//
pictureBoxExcavator.Dock = DockStyle.Fill;
pictureBoxExcavator.Location = new Point(0, 0);
- pictureBoxExcavator.Margin = new Padding(3, 4, 3, 4);
pictureBoxExcavator.Name = "pictureBoxExcavator";
- pictureBoxExcavator.Size = new Size(914, 600);
+ pictureBoxExcavator.Size = new Size(800, 450);
pictureBoxExcavator.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxExcavator.TabIndex = 0;
pictureBoxExcavator.TabStop = false;
@@ -54,10 +54,9 @@
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(14, 529);
- buttonCreate.Margin = new Padding(3, 4, 3, 4);
+ buttonCreate.Location = new Point(12, 397);
buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(177, 55);
+ buttonCreate.Size = new Size(155, 41);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать простой экскаватор";
buttonCreate.UseVisualStyleBackColor = true;
@@ -68,10 +67,9 @@
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.down;
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
- buttonDown.Location = new Point(825, 553);
- buttonDown.Margin = new Padding(3, 4, 3, 4);
+ buttonDown.Location = new Point(722, 415);
buttonDown.Name = "buttonDown";
- buttonDown.Size = new Size(34, 40);
+ buttonDown.Size = new Size(30, 30);
buttonDown.TabIndex = 2;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonMove_Click;
@@ -81,10 +79,9 @@
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.up;
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
- buttonUp.Location = new Point(825, 505);
- buttonUp.Margin = new Padding(3, 4, 3, 4);
+ buttonUp.Location = new Point(722, 379);
buttonUp.Name = "buttonUp";
- buttonUp.Size = new Size(34, 40);
+ buttonUp.Size = new Size(30, 30);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += buttonMove_Click;
@@ -94,10 +91,9 @@
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.left;
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
- buttonLeft.Location = new Point(784, 553);
- buttonLeft.Margin = new Padding(3, 4, 3, 4);
+ buttonLeft.Location = new Point(686, 415);
buttonLeft.Name = "buttonLeft";
- buttonLeft.Size = new Size(34, 40);
+ buttonLeft.Size = new Size(30, 30);
buttonLeft.TabIndex = 4;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += buttonMove_Click;
@@ -107,10 +103,9 @@
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.right;
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
- buttonRight.Location = new Point(866, 553);
- buttonRight.Margin = new Padding(3, 4, 3, 4);
+ buttonRight.Location = new Point(758, 415);
buttonRight.Name = "buttonRight";
- buttonRight.Size = new Size(34, 40);
+ buttonRight.Size = new Size(30, 30);
buttonRight.TabIndex = 5;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonMove_Click;
@@ -120,18 +115,16 @@
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "Двигаться в центр", "Двигаться к краю экрана" });
- comboBoxStrategy.Location = new Point(762, 16);
- comboBoxStrategy.Margin = new Padding(3, 4, 3, 4);
+ comboBoxStrategy.Location = new Point(667, 12);
comboBoxStrategy.Name = "comboBoxStrategy";
- comboBoxStrategy.Size = new Size(138, 28);
+ comboBoxStrategy.Size = new Size(121, 23);
comboBoxStrategy.TabIndex = 6;
//
// buttonCreateExcavatorBodyKits
//
- buttonCreateExcavatorBodyKits.Location = new Point(198, 529);
- buttonCreateExcavatorBodyKits.Margin = new Padding(3, 4, 3, 4);
+ buttonCreateExcavatorBodyKits.Location = new Point(173, 397);
buttonCreateExcavatorBodyKits.Name = "buttonCreateExcavatorBodyKits";
- buttonCreateExcavatorBodyKits.Size = new Size(166, 55);
+ buttonCreateExcavatorBodyKits.Size = new Size(145, 41);
buttonCreateExcavatorBodyKits.TabIndex = 7;
buttonCreateExcavatorBodyKits.Text = "Создать Экскаватор с обвесами";
buttonCreateExcavatorBodyKits.UseVisualStyleBackColor = true;
@@ -139,20 +132,30 @@
//
// buttonStep
//
- buttonStep.Location = new Point(815, 55);
- buttonStep.Margin = new Padding(3, 4, 3, 4);
+ buttonStep.Location = new Point(713, 41);
buttonStep.Name = "buttonStep";
- buttonStep.Size = new Size(86, 31);
+ buttonStep.Size = new Size(75, 23);
buttonStep.TabIndex = 8;
buttonStep.Text = "Шаг";
buttonStep.UseVisualStyleBackColor = true;
buttonStep.Click += buttonStep_Click;
//
+ // buttonSelectObject
+ //
+ buttonSelectObject.Location = new Point(713, 70);
+ buttonSelectObject.Name = "buttonSelectObject";
+ buttonSelectObject.Size = new Size(75, 23);
+ buttonSelectObject.TabIndex = 9;
+ buttonSelectObject.Text = "Выбрать объект";
+ buttonSelectObject.UseVisualStyleBackColor = true;
+ buttonSelectObject.Click += buttonSelectObject_Click;
+ //
// ExcavatorForm
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(914, 600);
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonSelectObject);
Controls.Add(buttonStep);
Controls.Add(buttonCreateExcavatorBodyKits);
Controls.Add(comboBoxStrategy);
@@ -162,7 +165,6 @@
Controls.Add(buttonDown);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxExcavator);
- Margin = new Padding(3, 4, 3, 4);
Name = "ExcavatorForm";
Text = "Excavator";
Click += buttonMove_Click;
@@ -182,5 +184,6 @@
private ComboBox comboBoxStrategy;
private Button buttonCreateExcavatorBodyKits;
private Button buttonStep;
+ private Button buttonSelectObject;
}
}
\ No newline at end of file
diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
index c8a16f1..95bad8d 100644
--- a/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorForm.cs
@@ -13,12 +13,15 @@ namespace ProjectExcavator
///
///
private AbstractStrategy? _abstractStrategy;
+ public DrawningExcavator? SelectedExcavator { get; private set; }
///
///
///
public ExcavatorForm()
{
InitializeComponent();
+ _drawnigExcavator = null;
+ _abstractStrategy = null;
}
///
///
@@ -84,12 +87,24 @@ namespace ProjectExcavator
private void buttonCreateExcavatorBodyKits_Click(object sender, EventArgs e)
{
Random random = new();
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog mainDialog = new ColorDialog();
+ if (mainDialog.ShowDialog() == DialogResult.OK)
+ {
+ color = mainDialog.Color;
+ }
+ Color dopcolor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dopDialog = new ColorDialog();
+ if (dopDialog.ShowDialog() == DialogResult.OK)
+ {
+ dopcolor = dopDialog.Color;
+ }
_drawnigExcavator = new DrawningExcavarorBodyKits(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)),
+ color,
+ dopcolor,
+ true,
+ true,
pictureBoxExcavator.Width,
pictureBoxExcavator.Height);
_drawnigExcavator.SetPosition(random.Next(10, 100), random.Next(10, 100));
@@ -131,5 +146,10 @@ namespace ProjectExcavator
_abstractStrategy = null;
}
}
+ private void buttonSelectObject_Click(object sender, EventArgs e)
+ {
+ SelectedExcavator = _drawnigExcavator;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs
new file mode 100644
index 0000000..d27f410
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectExcavator.MovementStrategy;
+using ProjectExcavator.DrawningObjects;
+using ProjectExcavator.Generic;
+
+namespace ProjectExcavator.Generic
+{
+ internal class ExcavatorGenericCollection
+ where T : DrawningExcavator
+ where U : IMoveableObject
+ {
+ private readonly int _pictureWidth;
+ private readonly int _pictureHeight;
+ private readonly int _placeSizeWidth = 210;
+ private readonly int _placeSizeHeight = 110;
+ private readonly SetGeneric _collection;
+ public ExcavatorGenericCollection(int picWidth, int picHeight)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = new SetGeneric(width * height);
+ }
+ public static bool operator +(ExcavatorGenericCollection collect, T? obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+ return collect?._collection.Insert(obj) ?? false;
+ }
+ public static T? operator -(ExcavatorGenericCollection collect, int pos)
+ {
+ T? obj = collect._collection.Get(pos);
+ if (obj != null)
+ {
+ collect._collection.Remove(pos);
+ }
+ return obj;
+ }
+
+ public U? GetU(int pos) => (U)_collection.Get(pos)?.GetMoveableObject;
+ ///
+ /// Вывод всего набора объектов
+ ///
+ ///
+ public Bitmap ShowExcavator()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawObjects(gr);
+ return bmp;
+ }
+ 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; j++)
+ {
+ g.DrawLine(pen, i * i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
+ }
+ g.DrawLine(pen, i * _placeSizeWidth, 0, i *
+ _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
+ }
+ }
+ private void DrawObjects(Graphics g)
+ {
+ for(int i = 0; i < _collection.Count;i++)
+ {
+ T t = _collection.Get(i);
+ if(t != null)
+ {
+ t.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
+ if (t is DrawningExcavator)
+ {
+ //тут преведение избыточно
+ t.DrawTransport(g);
+ }
+ else
+ {
+ t.DrawTransport(g);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs
new file mode 100644
index 0000000..8edecb0
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs
@@ -0,0 +1,109 @@
+namespace ProjectExcavator
+{
+ partial class FormExcavatorCollection
+ {
+ ///
+ /// 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()
+ {
+ pictureBoxCollection = new PictureBox();
+ buttonAddExcavator = new Button();
+ maskedTextBoxNumber = new MaskedTextBox();
+ buttonRemoveExcavator = new Button();
+ buttonRefreshCollection = new Button();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxCollection
+ //
+ pictureBoxCollection.Location = new Point(0, 0);
+ pictureBoxCollection.Name = "pictureBoxCollection";
+ pictureBoxCollection.Size = new Size(617, 450);
+ pictureBoxCollection.TabIndex = 0;
+ pictureBoxCollection.TabStop = false;
+ //
+ // buttonAddExcavator
+ //
+ buttonAddExcavator.Location = new Point(623, 26);
+ buttonAddExcavator.Name = "buttonAddExcavator";
+ buttonAddExcavator.Size = new Size(174, 51);
+ buttonAddExcavator.TabIndex = 1;
+ buttonAddExcavator.Text = "Добавить экскавотор";
+ buttonAddExcavator.UseVisualStyleBackColor = true;
+ buttonAddExcavator.Click += buttonAddExcavator_Click;
+ //
+ // maskedTextBoxNumber
+ //
+ maskedTextBoxNumber.Location = new Point(623, 83);
+ maskedTextBoxNumber.Name = "maskedTextBoxNumber";
+ maskedTextBoxNumber.Size = new Size(174, 23);
+ maskedTextBoxNumber.TabIndex = 2;
+ //
+ // buttonRemoveExcavator
+ //
+ buttonRemoveExcavator.Location = new Point(623, 128);
+ buttonRemoveExcavator.Name = "buttonRemoveExcavator";
+ buttonRemoveExcavator.Size = new Size(174, 38);
+ buttonRemoveExcavator.TabIndex = 3;
+ buttonRemoveExcavator.Text = "Удалить объект";
+ buttonRemoveExcavator.UseVisualStyleBackColor = true;
+ buttonRemoveExcavator.Click += buttonRemoveExcavator_Click;
+ //
+ // buttonRefreshCollection
+ //
+ buttonRefreshCollection.Location = new Point(625, 172);
+ buttonRefreshCollection.Name = "buttonRefreshCollection";
+ buttonRefreshCollection.Size = new Size(172, 33);
+ buttonRefreshCollection.TabIndex = 4;
+ buttonRefreshCollection.Text = "Обновить коллекцию";
+ buttonRefreshCollection.UseVisualStyleBackColor = true;
+ buttonRefreshCollection.Click += buttonRefreshCollection_Click;
+ //
+ // FormExcavatorCollection
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonRefreshCollection);
+ Controls.Add(buttonRemoveExcavator);
+ Controls.Add(maskedTextBoxNumber);
+ Controls.Add(buttonAddExcavator);
+ Controls.Add(pictureBoxCollection);
+ Name = "FormExcavatorCollection";
+ Text = "Набор экскаваторов";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxCollection;
+ private Button buttonAddExcavator;
+ private MaskedTextBox maskedTextBoxNumber;
+ private Button buttonRemoveExcavator;
+ private Button buttonRefreshCollection;
+ }
+}
\ No newline at end of file
diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs
new file mode 100644
index 0000000..bf77445
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs
@@ -0,0 +1,64 @@
+using ProjectExcavator.DrawningObjects;
+using ProjectExcavator.Generic;
+using ProjectExcavator.MovementStrategy;
+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;
+
+namespace ProjectExcavator
+{
+ public partial class FormExcavatorCollection : Form
+ {
+ private readonly ExcavatorGenericCollection _excavators;
+
+ public FormExcavatorCollection()
+ {
+ InitializeComponent();
+ _excavators = new ExcavatorGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height);
+ }
+ private void buttonAddExcavator_Click(object sender, EventArgs e)
+ {
+ ExcavatorForm form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_excavators + form.SelectedExcavator)
+ {
+ MessageBox.Show("Объект добален");
+ pictureBoxCollection.Image = _excavators.ShowExcavator();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить новый обьект");
+ }
+ }
+ }
+ private void buttonRemoveExcavator_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить объект?", "Удаление...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
+ if(_excavators - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBoxCollection.Image = _excavators.ShowExcavator();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить обхект");
+ }
+
+ }
+ private void buttonRefreshCollection_Click(object sender, EventArgs e)
+ {
+ pictureBoxCollection.Image = _excavators.ShowExcavator();
+ }
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.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/ProjectExcavator/ProjectExcavator/Program.cs b/ProjectExcavator/ProjectExcavator/Program.cs
index dc8b98b..8be0f08 100644
--- a/ProjectExcavator/ProjectExcavator/Program.cs
+++ b/ProjectExcavator/ProjectExcavator/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectExcavator
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new ExcavatorForm());
+ Application.Run(new FormExcavatorCollection());
}
}
}
\ No newline at end of file
diff --git a/ProjectExcavator/ProjectExcavator/SetGeneric.cs b/ProjectExcavator/ProjectExcavator/SetGeneric.cs
new file mode 100644
index 0000000..9ea67de
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/SetGeneric.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectExcavator
+{
+ internal class SetGeneric
+ where T : class
+ {
+ private readonly T?[] _places;
+ public int Count => _places.Length;
+ public SetGeneric(int count)
+ {
+ _places = new T?[count];
+ }
+ public bool Insert(T excavator)
+ {
+ int i = 0;
+ for (; i < _places.Length; i++)
+ {
+ if (_places[i] == null)
+ {
+ break;
+ }
+ }
+ if (i == _places.Length)
+ return false;
+ for (; i > 0; i--)
+ {
+ _places[i] = _places[i - 1];
+ }
+ _places[i] = excavator;
+ return true;
+ }
+ public bool Insert(T excavator, int position)
+ {
+ if (position < 0 || position >= _places.Length)
+ return false;
+ for (; position < _places.Length; position++)
+ {
+ if (_places[position] == null)
+ {
+ break;
+ }
+ }
+ if (position == _places.Length)
+ return false;
+ for (; position > 0; position--)
+ {
+ _places[position] = _places[position - 1];
+ }
+ _places[position] = excavator;
+ return true;
+ }
+ public bool Remove(int position) {
+ if (position >= _places.Length || position<0)
+ return false;
+ _places[position] = null;
+ return true;
+ }
+ public T? Get(int position)
+ {
+ if(position >= _places.Length || position < 0)
+ {
+ return null;
+ }
+ return _places[position];
+ }
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/Status.cs b/ProjectExcavator/ProjectExcavator/Status.cs
index 8f61c75..b6d0184 100644
--- a/ProjectExcavator/ProjectExcavator/Status.cs
+++ b/ProjectExcavator/ProjectExcavator/Status.cs
@@ -8,8 +8,8 @@ namespace ProjectExcavator
{
public enum Status
{
- NotInit = 0,
- InProgress = 1,
- Finish = 2
+ NotInit ,
+ InProgress,
+ Finish
}
}