From c269ff167a4097ba54993c43a72858bb4358248d Mon Sep 17 00:00:00 2001
From: Danil Malin <malin-03@mail.ru>
Date: Fri, 7 Oct 2022 13:54:37 +0400
Subject: [PATCH 1/5] =?UTF-8?q?=D0=A2=D1=80=D0=B5=D1=82=D1=8C=D1=8F=20?=
 =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?=
 =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../WarmlyLocomotive/Direction.cs             |   2 +-
 .../WarmlyLocomotive/DrawningLocomotive.cs    |   2 +-
 .../WarmlyLocomotive/EntityLocomotive.cs      |   2 +-
 .../FormLocomotive.Designer.cs                |  14 ++
 .../WarmlyLocomotive/FormLocomotive.cs        |  30 ++-
 .../WarmlyLocomotive/FormMap.Designer.cs      | 209 ----------------
 WarmlyLocomotive/WarmlyLocomotive/FormMap.cs  |  90 -------
 .../FormMapWithSetLocomotives.Designer.cs     | 225 ++++++++++++++++++
 .../FormMapWithSetLocomotives.cs              | 164 +++++++++++++
 ...ap.resx => FormMapWithSetLocomotives.resx} |   3 -
 .../MapWithSetLocomotivesGeneric.cs           | 200 ++++++++++++++++
 WarmlyLocomotive/WarmlyLocomotive/Program.cs  |   2 +-
 .../WarmlyLocomotive/SetLocomotivesGeneric.cs | 143 +++++++++++
 13 files changed, 776 insertions(+), 310 deletions(-)
 delete mode 100644 WarmlyLocomotive/WarmlyLocomotive/FormMap.Designer.cs
 delete mode 100644 WarmlyLocomotive/WarmlyLocomotive/FormMap.cs
 create mode 100644 WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.Designer.cs
 create mode 100644 WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
 rename WarmlyLocomotive/WarmlyLocomotive/{FormMap.resx => FormMapWithSetLocomotives.resx} (93%)
 create mode 100644 WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
 create mode 100644 WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs

diff --git a/WarmlyLocomotive/WarmlyLocomotive/Direction.cs b/WarmlyLocomotive/WarmlyLocomotive/Direction.cs
index 53e0dc8..0b3cb83 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/Direction.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/Direction.cs
@@ -9,7 +9,7 @@ namespace WarmlyLocomotive
     /// <summary>
     /// Направление перемещения
     /// </summary>
-    internal enum Direction
+    public enum Direction
     {
         None = 0,
         Up = 1,
diff --git a/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs
index 8145c57..ed7a3fe 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs
@@ -9,7 +9,7 @@ namespace WarmlyLocomotive
     /// <summary>
     /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
     /// </summary>
-    internal class DrawningLocomotive
+    public class DrawningLocomotive
     {
         /// <summary>
         /// Класс-сущность
diff --git a/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs
index 36ee67c..59c79c5 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
 
 namespace WarmlyLocomotive
 {
-    internal class EntityLocomotive
+    public class EntityLocomotive
     {
         /// <summary>
         /// Скорость
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.Designer.cs b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.Designer.cs
index 843fe60..b3b4cbb 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.Designer.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.Designer.cs
@@ -39,6 +39,7 @@
             this.buttonDown = new System.Windows.Forms.Button();
             this.buttonLeft = new System.Windows.Forms.Button();
             this.buttonCreateModif = new System.Windows.Forms.Button();
+            this.buttonSelectLocomotive = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
             this.statusStrip.SuspendLayout();
             this.SuspendLayout();
@@ -153,11 +154,23 @@
             this.buttonCreateModif.UseVisualStyleBackColor = true;
             this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
             // 
+            // buttonSelectLocomotive
+            // 
+            this.buttonSelectLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonSelectLocomotive.Location = new System.Drawing.Point(618, 415);
+            this.buttonSelectLocomotive.Name = "buttonSelectLocomotive";
+            this.buttonSelectLocomotive.Size = new System.Drawing.Size(75, 23);
+            this.buttonSelectLocomotive.TabIndex = 8;
+            this.buttonSelectLocomotive.Text = "Выбрать";
+            this.buttonSelectLocomotive.UseVisualStyleBackColor = true;
+            this.buttonSelectLocomotive.Click += new System.EventHandler(this.ButtonSelectLocomotive_Click);
+            // 
             // FormLocomotive
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(837, 483);
+            this.Controls.Add(this.buttonSelectLocomotive);
             this.Controls.Add(this.buttonCreateModif);
             this.Controls.Add(this.buttonLeft);
             this.Controls.Add(this.buttonDown);
@@ -190,5 +203,6 @@
         private Button buttonDown;
         private Button buttonLeft;
         private Button buttonCreateModif;
+        private Button buttonSelectLocomotive;
     }
 }
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs
index f46b6f9..a49a5e6 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs
@@ -3,6 +3,7 @@ namespace WarmlyLocomotive
     public partial class FormLocomotive : Form
     {
         private DrawningLocomotive _locomotive;
+        public DrawningLocomotive SelectedLocomotive { get; private set; }
         public FormLocomotive()
         {
             InitializeComponent();
@@ -36,7 +37,13 @@ namespace WarmlyLocomotive
         private void ButtonCreate_Click(object sender, EventArgs e)
         {
             Random rnd = new();
-            _locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+            Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+            ColorDialog dialog = new();
+            if (dialog.ShowDialog() == DialogResult.OK)
+            {
+                color = dialog.Color;
+            }
+            _locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
             SetData();
             Draw();
         }
@@ -68,12 +75,27 @@ namespace WarmlyLocomotive
         private void ButtonCreateModif_Click(object sender, EventArgs e)
         {
             Random rnd = new();
-            _locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
-                Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
-                Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
+            Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+            ColorDialog dialog = new();
+            if (dialog.ShowDialog() == DialogResult.OK)
+            {
+                color = dialog.Color;
+            }
+            Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+            ColorDialog dialogDop = new();
+            if (dialogDop.ShowDialog() == DialogResult.OK)
+            {
+                dopColor = dialogDop.Color;
+            }
+            _locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
                 Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
             SetData();
             Draw();
         }
+        private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
+        {
+            SelectedLocomotive = _locomotive;
+            DialogResult = DialogResult.OK;
+        }
     }
 }
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMap.Designer.cs b/WarmlyLocomotive/WarmlyLocomotive/FormMap.Designer.cs
deleted file mode 100644
index 62fd506..0000000
--- a/WarmlyLocomotive/WarmlyLocomotive/FormMap.Designer.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-namespace WarmlyLocomotive
-{
-    partial class FormMap
-    {
-        /// <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.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
-            this.statusStrip = new System.Windows.Forms.StatusStrip();
-            this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
-            this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
-            this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
-            this.buttonCreate = new System.Windows.Forms.Button();
-            this.buttonRight = new System.Windows.Forms.Button();
-            this.buttonUp = new System.Windows.Forms.Button();
-            this.buttonDown = new System.Windows.Forms.Button();
-            this.buttonLeft = new System.Windows.Forms.Button();
-            this.buttonCreateModif = new System.Windows.Forms.Button();
-            this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
-            this.statusStrip.SuspendLayout();
-            this.SuspendLayout();
-            // 
-            // pictureBoxLocomotive
-            // 
-            this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
-            this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
-            this.pictureBoxLocomotive.Size = new System.Drawing.Size(837, 461);
-            this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
-            this.pictureBoxLocomotive.TabIndex = 0;
-            this.pictureBoxLocomotive.TabStop = false;
-            // 
-            // statusStrip
-            // 
-            this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.toolStripStatusLabelSpeed,
-            this.toolStripStatusLabelWeight,
-            this.toolStripStatusLabelBodyColor});
-            this.statusStrip.Location = new System.Drawing.Point(0, 461);
-            this.statusStrip.Name = "statusStrip";
-            this.statusStrip.Size = new System.Drawing.Size(837, 22);
-            this.statusStrip.TabIndex = 1;
-            // 
-            // toolStripStatusLabelSpeed
-            // 
-            this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
-            this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
-            this.toolStripStatusLabelSpeed.Text = "Скорость:";
-            // 
-            // toolStripStatusLabelWeight
-            // 
-            this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
-            this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
-            this.toolStripStatusLabelWeight.Text = "Вес:";
-            // 
-            // toolStripStatusLabelBodyColor
-            // 
-            this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
-            this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
-            this.toolStripStatusLabelBodyColor.Text = "Цвет:";
-            // 
-            // buttonCreate
-            // 
-            this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.buttonCreate.Location = new System.Drawing.Point(12, 418);
-            this.buttonCreate.Name = "buttonCreate";
-            this.buttonCreate.Size = new System.Drawing.Size(75, 23);
-            this.buttonCreate.TabIndex = 2;
-            this.buttonCreate.Text = "Создать";
-            this.buttonCreate.UseVisualStyleBackColor = true;
-            this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
-            // 
-            // buttonRight
-            // 
-            this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowRight;
-            this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.buttonRight.Location = new System.Drawing.Point(795, 411);
-            this.buttonRight.Name = "buttonRight";
-            this.buttonRight.Size = new System.Drawing.Size(30, 30);
-            this.buttonRight.TabIndex = 3;
-            this.buttonRight.UseVisualStyleBackColor = true;
-            this.buttonRight.Click += new System.EventHandler(this.ButtonMove_click);
-            // 
-            // buttonUp
-            // 
-            this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowUp;
-            this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.buttonUp.Location = new System.Drawing.Point(759, 375);
-            this.buttonUp.Name = "buttonUp";
-            this.buttonUp.Size = new System.Drawing.Size(30, 30);
-            this.buttonUp.TabIndex = 4;
-            this.buttonUp.UseVisualStyleBackColor = true;
-            this.buttonUp.Click += new System.EventHandler(this.ButtonMove_click);
-            // 
-            // buttonDown
-            // 
-            this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowDown;
-            this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.buttonDown.Location = new System.Drawing.Point(759, 411);
-            this.buttonDown.Name = "buttonDown";
-            this.buttonDown.Size = new System.Drawing.Size(30, 30);
-            this.buttonDown.TabIndex = 5;
-            this.buttonDown.UseVisualStyleBackColor = true;
-            this.buttonDown.Click += new System.EventHandler(this.ButtonMove_click);
-            // 
-            // buttonLeft
-            // 
-            this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
-            this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowLeft;
-            this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.buttonLeft.Location = new System.Drawing.Point(723, 411);
-            this.buttonLeft.Name = "buttonLeft";
-            this.buttonLeft.Size = new System.Drawing.Size(30, 30);
-            this.buttonLeft.TabIndex = 6;
-            this.buttonLeft.UseVisualStyleBackColor = true;
-            this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_click);
-            // 
-            // buttonCreateModif
-            // 
-            this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.buttonCreateModif.Location = new System.Drawing.Point(105, 418);
-            this.buttonCreateModif.Name = "buttonCreateModif";
-            this.buttonCreateModif.Size = new System.Drawing.Size(110, 23);
-            this.buttonCreateModif.TabIndex = 7;
-            this.buttonCreateModif.Text = "Модификация";
-            this.buttonCreateModif.UseVisualStyleBackColor = true;
-            this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
-            // 
-            // comboBoxSelectorMap
-            // 
-            this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.comboBoxSelectorMap.FormattingEnabled = true;
-            this.comboBoxSelectorMap.Items.AddRange(new object[] {
-            "Простая карта",
-            "Карта с большими барьерами",
-            "Карта с барьерами-кругами"});
-            this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
-            this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
-            this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);
-            this.comboBoxSelectorMap.TabIndex = 8;
-            this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
-            // 
-            // FormMap
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(837, 483);
-            this.Controls.Add(this.comboBoxSelectorMap);
-            this.Controls.Add(this.buttonCreateModif);
-            this.Controls.Add(this.buttonLeft);
-            this.Controls.Add(this.buttonDown);
-            this.Controls.Add(this.buttonUp);
-            this.Controls.Add(this.buttonRight);
-            this.Controls.Add(this.buttonCreate);
-            this.Controls.Add(this.pictureBoxLocomotive);
-            this.Controls.Add(this.statusStrip);
-            this.Name = "FormMap";
-            this.Text = "Карта";
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
-            this.statusStrip.ResumeLayout(false);
-            this.statusStrip.PerformLayout();
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private PictureBox pictureBoxLocomotive;
-        private StatusStrip statusStrip;
-        private ToolStripStatusLabel toolStripStatusLabelSpeed;
-        private ToolStripStatusLabel toolStripStatusLabelWeight;
-        private ToolStripStatusLabel toolStripStatusLabelBodyColor;
-        private Button buttonCreate;
-        private Button buttonRight;
-        private Button buttonUp;
-        private Button buttonDown;
-        private Button buttonLeft;
-        private Button buttonCreateModif;
-        private ComboBox comboBoxSelectorMap;
-    }
-}
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMap.cs b/WarmlyLocomotive/WarmlyLocomotive/FormMap.cs
deleted file mode 100644
index 362576d..0000000
--- a/WarmlyLocomotive/WarmlyLocomotive/FormMap.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-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 WarmlyLocomotive
-{
-    public partial class FormMap : Form
-    {
-        private AbstractMap _abstractMap;
-        public FormMap()
-        {
-            InitializeComponent();
-            _abstractMap = new SimpleMap();
-        }
-        /// <summary>
-        /// Заполнение информации по объекту
-        /// </summary>
-        /// <param name="car"></param>
-        private void SetData(DrawningLocomotive locomotive)
-        {
-            toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
-            toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
-            toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
-            pictureBoxLocomotive.Image = _abstractMap.CreateMap(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height,
-                new DrawningObjectLocomotive(locomotive));
-        }
-        /// <summary>
-        /// Обработка нажатия кнопки "Создать"
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ButtonCreate_Click(object sender, EventArgs e)
-        {
-            Random rnd = new();
-            var locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
-            SetData(locomotive);
-        }
-        private void ButtonMove_click(object sender, EventArgs e)
-        {
-            string name = ((Button)sender)?.Name ?? string.Empty;
-            Direction dir = Direction.None;
-            switch (name)
-            {
-                case "buttonUp":
-                    dir = Direction.Up;
-                    break;
-                case "buttonDown":
-                    dir = Direction.Down;
-                    break;
-                case "buttonLeft":
-                    dir = Direction.Left;
-                    break;
-                case "buttonRight":
-                    dir = Direction.Right;
-                    break;
-            }
-            pictureBoxLocomotive.Image = _abstractMap?.MoveObject(dir);
-        }
-        private void ButtonCreateModif_Click(object sender, EventArgs e)
-        {
-            Random rnd = new();
-            var locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
-                Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
-                Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
-                Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
-            SetData(locomotive);
-        }
-        private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
-        {
-            switch (comboBoxSelectorMap.Text)
-            {
-                case "Простая карта":
-                    _abstractMap = new SimpleMap();
-                    break;
-                case "Карта с большими барьерами":
-                    _abstractMap = new BigBarriersMap();
-                    break;
-                case "Карта с барьерами-кругами":
-                    _abstractMap = new CirclesMap();
-                    break;
-            }
-        }
-    }
-}
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.Designer.cs b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.Designer.cs
new file mode 100644
index 0000000..f17a7ae
--- /dev/null
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.Designer.cs
@@ -0,0 +1,225 @@
+namespace WarmlyLocomotive
+{
+    partial class FormMapWithSetLocomotives
+    {
+        /// <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.groupBox = new System.Windows.Forms.GroupBox();
+            this.buttonDown = new System.Windows.Forms.Button();
+            this.buttonRight = new System.Windows.Forms.Button();
+            this.buttonLeft = 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.buttonRemoveLocomotive = new System.Windows.Forms.Button();
+            this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+            this.buttonAddLocomotive = new System.Windows.Forms.Button();
+            this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+            this.pictureBox = new System.Windows.Forms.PictureBox();
+            this.groupBox.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // groupBox
+            // 
+            this.groupBox.Controls.Add(this.buttonDown);
+            this.groupBox.Controls.Add(this.buttonRight);
+            this.groupBox.Controls.Add(this.buttonLeft);
+            this.groupBox.Controls.Add(this.buttonUp);
+            this.groupBox.Controls.Add(this.buttonShowOnMap);
+            this.groupBox.Controls.Add(this.buttonShowStorage);
+            this.groupBox.Controls.Add(this.buttonRemoveLocomotive);
+            this.groupBox.Controls.Add(this.maskedTextBoxPosition);
+            this.groupBox.Controls.Add(this.buttonAddLocomotive);
+            this.groupBox.Controls.Add(this.comboBoxSelectorMap);
+            this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
+            this.groupBox.Location = new System.Drawing.Point(600, 0);
+            this.groupBox.Name = "groupBox";
+            this.groupBox.Size = new System.Drawing.Size(200, 450);
+            this.groupBox.TabIndex = 0;
+            this.groupBox.TabStop = false;
+            this.groupBox.Text = "Инструменты";
+            // 
+            // buttonDown
+            // 
+            this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonDown.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowDown;
+            this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.buttonDown.Location = new System.Drawing.Point(87, 403);
+            this.buttonDown.Name = "buttonDown";
+            this.buttonDown.Size = new System.Drawing.Size(30, 30);
+            this.buttonDown.TabIndex = 9;
+            this.buttonDown.UseVisualStyleBackColor = true;
+            this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+            // 
+            // buttonRight
+            // 
+            this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonRight.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowRight;
+            this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.buttonRight.Location = new System.Drawing.Point(123, 403);
+            this.buttonRight.Name = "buttonRight";
+            this.buttonRight.Size = new System.Drawing.Size(30, 30);
+            this.buttonRight.TabIndex = 8;
+            this.buttonRight.UseVisualStyleBackColor = true;
+            this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+            // 
+            // buttonLeft
+            // 
+            this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonLeft.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowLeft;
+            this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.buttonLeft.Location = new System.Drawing.Point(51, 403);
+            this.buttonLeft.Name = "buttonLeft";
+            this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+            this.buttonLeft.TabIndex = 7;
+            this.buttonLeft.UseVisualStyleBackColor = true;
+            this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+            // 
+            // buttonUp
+            // 
+            this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonUp.BackgroundImage = global::WarmlyLocomotive.Properties.Resources.arrowUp;
+            this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.buttonUp.Location = new System.Drawing.Point(87, 367);
+            this.buttonUp.Name = "buttonUp";
+            this.buttonUp.Size = new System.Drawing.Size(30, 30);
+            this.buttonUp.TabIndex = 6;
+            this.buttonUp.UseVisualStyleBackColor = true;
+            this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+            // 
+            // buttonShowOnMap
+            // 
+            this.buttonShowOnMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonShowOnMap.Location = new System.Drawing.Point(19, 312);
+            this.buttonShowOnMap.Name = "buttonShowOnMap";
+            this.buttonShowOnMap.Size = new System.Drawing.Size(169, 30);
+            this.buttonShowOnMap.TabIndex = 5;
+            this.buttonShowOnMap.Text = "Посмотреть карту";
+            this.buttonShowOnMap.UseVisualStyleBackColor = true;
+            this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
+            // 
+            // buttonShowStorage
+            // 
+            this.buttonShowStorage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonShowStorage.Location = new System.Drawing.Point(19, 233);
+            this.buttonShowStorage.Name = "buttonShowStorage";
+            this.buttonShowStorage.Size = new System.Drawing.Size(169, 30);
+            this.buttonShowStorage.TabIndex = 4;
+            this.buttonShowStorage.Text = "Посмотреть хранилище";
+            this.buttonShowStorage.UseVisualStyleBackColor = true;
+            this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+            // 
+            // buttonRemoveLocomotive
+            // 
+            this.buttonRemoveLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonRemoveLocomotive.Location = new System.Drawing.Point(19, 171);
+            this.buttonRemoveLocomotive.Name = "buttonRemoveLocomotive";
+            this.buttonRemoveLocomotive.Size = new System.Drawing.Size(169, 30);
+            this.buttonRemoveLocomotive.TabIndex = 3;
+            this.buttonRemoveLocomotive.Text = "Удалить локомотив";
+            this.buttonRemoveLocomotive.UseVisualStyleBackColor = true;
+            this.buttonRemoveLocomotive.Click += new System.EventHandler(this.ButtonRemoveLocomotive_Click);
+            // 
+            // maskedTextBoxPosition
+            // 
+            this.maskedTextBoxPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 142);
+            this.maskedTextBoxPosition.Mask = "00";
+            this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+            this.maskedTextBoxPosition.Size = new System.Drawing.Size(169, 23);
+            this.maskedTextBoxPosition.TabIndex = 2;
+            // 
+            // buttonAddLocomotive
+            // 
+            this.buttonAddLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.buttonAddLocomotive.Location = new System.Drawing.Point(19, 90);
+            this.buttonAddLocomotive.Name = "buttonAddLocomotive";
+            this.buttonAddLocomotive.Size = new System.Drawing.Size(169, 30);
+            this.buttonAddLocomotive.TabIndex = 1;
+            this.buttonAddLocomotive.Text = "Добавить локомотив";
+            this.buttonAddLocomotive.UseVisualStyleBackColor = true;
+            this.buttonAddLocomotive.Click += new System.EventHandler(this.ButtonAddLocomotive_Click);
+            // 
+            // comboBoxSelectorMap
+            // 
+            this.comboBoxSelectorMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxSelectorMap.FormattingEnabled = true;
+            this.comboBoxSelectorMap.Items.AddRange(new object[] {
+            "Простая карта",
+            "Карта с большими барьерами",
+            "Карта с круглыми барьерами"});
+            this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 33);
+            this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+            this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 23);
+            this.comboBoxSelectorMap.TabIndex = 0;
+            this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
+            // 
+            // pictureBox
+            // 
+            this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.pictureBox.Location = new System.Drawing.Point(0, 0);
+            this.pictureBox.Name = "pictureBox";
+            this.pictureBox.Size = new System.Drawing.Size(600, 450);
+            this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+            this.pictureBox.TabIndex = 1;
+            this.pictureBox.TabStop = false;
+            // 
+            // FormMapWithSetLocomotives
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Controls.Add(this.pictureBox);
+            this.Controls.Add(this.groupBox);
+            this.Name = "FormMapWithSetLocomotives";
+            this.Text = "FormMapWithSetLocomotives";
+            this.groupBox.ResumeLayout(false);
+            this.groupBox.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private GroupBox groupBox;
+        private Button buttonDown;
+        private Button buttonRight;
+        private Button buttonLeft;
+        private Button buttonUp;
+        private Button buttonShowOnMap;
+        private Button buttonShowStorage;
+        private Button buttonRemoveLocomotive;
+        private MaskedTextBox maskedTextBoxPosition;
+        private Button buttonAddLocomotive;
+        private ComboBox comboBoxSelectorMap;
+        private PictureBox pictureBox;
+    }
+}
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
new file mode 100644
index 0000000..f512cb6
--- /dev/null
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
@@ -0,0 +1,164 @@
+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 static System.Windows.Forms.DataFormats;
+
+namespace WarmlyLocomotive
+{
+    public partial class FormMapWithSetLocomotives : Form
+    {
+        /// <summary>
+        /// Объект от класса карты с набором объектов
+        /// </summary>
+        private MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap> _mapLocomotivesCollectionGeneric;
+        public FormMapWithSetLocomotives()
+        {
+            InitializeComponent();
+        }
+        /// <summary>
+        /// Выбор карты
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            AbstractMap map = null;
+            switch (comboBoxSelectorMap.Text)
+            {
+                case "Простая карта":
+                    map = new SimpleMap();
+                    break;
+                case "Карта с большими барьерами":
+                    map = new BigBarriersMap();
+                    break;
+                case "Карта с круглыми барьерами":
+                    map = new CirclesMap();
+                    break;
+            }
+            if (map != null)
+            {
+                _mapLocomotivesCollectionGeneric = new MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>(
+                    pictureBox.Width, pictureBox.Height, map);
+            }
+            else
+            {
+                _mapLocomotivesCollectionGeneric = null;
+            }
+        }
+        /// <summary>
+        /// Добавление объекта
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonAddLocomotive_Click(object sender, EventArgs e)
+        {
+            if (_mapLocomotivesCollectionGeneric == null)
+            {
+                return;
+            }
+            FormLocomotive form = new();
+            if (form.ShowDialog() == DialogResult.OK)
+            {
+                DrawningObjectLocomotive car = new(form.SelectedLocomotive);
+                if (_mapLocomotivesCollectionGeneric + car != -1)
+                {
+                    MessageBox.Show("Объект добавлен");
+                    pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
+                }
+                else
+                {
+                    MessageBox.Show("Не удалось добавить объект");
+                }
+            }
+        }
+        /// <summary>
+        /// Удаление объекта
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
+        {
+            if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
+            {
+                return;
+            }
+            if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+            {
+                return;
+            }
+            int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+            if (_mapLocomotivesCollectionGeneric - pos != null)
+            {
+                MessageBox.Show("Объект удален");
+                pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
+            }
+            else
+            {
+                MessageBox.Show("Не удалось удалить объект");
+            }
+        }
+        /// <summary>
+        /// Вывод набора
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonShowStorage_Click(object sender, EventArgs e)
+        {
+            if (_mapLocomotivesCollectionGeneric == null)
+            {
+                return;
+            }
+            pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
+        }
+        /// <summary>
+        /// Вывод карты
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonShowOnMap_Click(object sender, EventArgs e)
+        {
+            if (_mapLocomotivesCollectionGeneric == null)
+            {
+                return;
+            }
+            pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowOnMap();
+        }
+        /// <summary>
+        /// Перемещение
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonMove_Click(object sender, EventArgs e)
+        {
+            if (_mapLocomotivesCollectionGeneric == null)
+            {
+                return;
+            }
+            //получаем имя кнопки
+            string name = ((Button)sender)?.Name ?? string.Empty;
+            Direction dir = Direction.None;
+            switch (name)
+            {
+                case "buttonUp":
+                    dir = Direction.Up;
+                    break;
+                case "buttonDown":
+                    dir = Direction.Down;
+                    break;
+                case "buttonLeft":
+                    dir = Direction.Left;
+                    break;
+                case "buttonRight":
+                    dir = Direction.Right;
+                    break;
+            }
+            pictureBox.Image = _mapLocomotivesCollectionGeneric.MoveObject(dir);
+        }
+    }
+}
diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMap.resx b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.resx
similarity index 93%
rename from WarmlyLocomotive/WarmlyLocomotive/FormMap.resx
rename to WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.resx
index 2c0949d..f298a7b 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/FormMap.resx
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.resx
@@ -57,7 +57,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
-  </metadata>
 </root>
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
new file mode 100644
index 0000000..aca2892
--- /dev/null
+++ b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
@@ -0,0 +1,200 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyLocomotive
+{
+    internal class MapWithSetLocomotivesGeneric<T, U>
+        where T : class, IDrawningObject
+        where U : AbstractMap
+    {
+        /// <summary>
+        /// Ширина окна отрисовки
+        /// </summary>
+        private readonly int _pictureWidth;
+        /// <summary>
+        /// Высота окна отрисовки
+        /// </summary>
+        private readonly int _pictureHeight;
+        /// <summary>
+        /// Размер занимаемого объектом места (ширина)
+        /// </summary>
+        private readonly int _placeSizeWidth = 210;
+        /// <summary>
+        /// Размер занимаемого объектом места (высота)
+        /// </summary>
+        private readonly int _placeSizeHeight = 120 /*105*/;
+        /// <summary>
+        /// Набор объектов
+        /// </summary>
+        private readonly SetLocomotivesGeneric<T> _setLocomotives;
+        /// <summary>
+        /// Карта
+        /// </summary>
+        private readonly U _map;
+        /// <summary>
+        /// Конструктор
+        /// </summary>
+        /// <param name="picWidth"></param>
+        /// <param name="picHeight"></param>
+        /// <param name="map"></param>
+        public MapWithSetLocomotivesGeneric(int picWidth, int picHeight, U map)
+        {
+            int width = picWidth / _placeSizeWidth;
+            int height = picHeight / _placeSizeHeight;
+            _setLocomotives = new SetLocomotivesGeneric<T>(width * height);
+            _pictureWidth = picWidth;
+            _pictureHeight = picHeight;
+            _map = map;
+        }
+        /// <summary>
+        /// Перегрузка оператора сложения
+        /// </summary>
+        /// <param name="map"></param>
+        /// <param name="locomotive"></param>
+        /// <returns></returns>
+        public static int operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
+        {
+            return map._setLocomotives.Insert(locomotive);
+        }
+        /// <summary>
+        /// Перегрузка оператора вычитания
+        /// </summary>
+        /// <param name="map"></param>
+        /// <param name="position"></param>
+        /// <returns></returns>
+        public static T operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
+        {
+            return map._setLocomotives.Remove(position);
+        }
+        /// <summary>
+        /// Вывод всего набора объектов
+        /// </summary>
+        /// <returns></returns>
+        public Bitmap ShowSet()
+        {
+            Bitmap bmp = new(_pictureWidth, _pictureHeight);
+            Graphics gr = Graphics.FromImage(bmp);
+            DrawBackground(gr);
+            DrawLocomotives(gr);
+            return bmp;
+        }
+        /// <summary>
+        /// Просмотр объекта на карте
+        /// </summary>
+        /// <returns></returns>
+        public Bitmap ShowOnMap()
+        {
+            Shaking();
+            for (int i = 0; i < _setLocomotives.Count; i++)
+            {
+                var locomotive = _setLocomotives.Get(i);
+                if (locomotive != null)
+                {
+                    return _map.CreateMap(_pictureWidth, _pictureHeight, locomotive);
+                }
+            }
+            return new(_pictureWidth, _pictureHeight);
+        }
+        /// <summary>
+        /// Перемещение объекта по крате
+        /// </summary>
+        /// <param name="direction"></param>
+        /// <returns></returns>
+        public Bitmap MoveObject(Direction direction)
+        {
+            if (_map != null)
+            {
+                return _map.MoveObject(direction);
+            }
+            return new(_pictureWidth, _pictureHeight);
+        }
+        /// <summary>
+        /// "Взбалтываем" набор, чтобы все элементы оказались в начале
+        /// </summary>
+        private void Shaking()
+        {
+            int j = _setLocomotives.Count - 1;
+            for (int i = 0; i < _setLocomotives.Count; i++)
+            {
+                if (_setLocomotives.Get(i) == null)
+                {
+                    for (; j > i; j--)
+                    {
+                        var locomotive = _setLocomotives.Get(j);
+                        if (locomotive != null)
+                        {
+                            _setLocomotives.Insert(locomotive, i);
+                            _setLocomotives.Remove(j);
+                            break;
+                        }
+                    }
+                    if (j <= i)
+                    {
+                        return;
+                    }
+                }
+            }
+        }
+        /// <summary>
+        /// Метод отрисовки фона
+        /// </summary>
+        /// <param name="g"></param>
+        private void DrawBackground(Graphics g)
+        {
+            Pen pen = new(Color.Black, 3);
+            Pen penTwo = new(Color.Black, 2);
+            Brush brushLightGray = new SolidBrush(Color.LightGray);
+            Brush brushBrown = new SolidBrush(Color.Brown);
+            g.FillRectangle(brushLightGray, 0, 0, _pictureWidth, _pictureHeight);
+            for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+            {
+                for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
+                {//линия рамзетки места
+                    if (j != 0)
+                    {
+                        int x = i * (_placeSizeWidth + 30);
+                        g.DrawLine(penTwo, x, j * _placeSizeHeight, x + _placeSizeWidth - 20, j * _placeSizeHeight);
+                        g.DrawLine(penTwo, x, j * _placeSizeHeight - 20, x + _placeSizeWidth - 20, j * _placeSizeHeight - 20);
+                        for (int k = 0; k < (_placeSizeWidth - 20) / 15; ++k)
+                        {
+                            g.FillRectangle(brushBrown, x, j * _placeSizeHeight - 20, 5, 20);
+                            x += 15;
+                        }
+                    }
+                    g.DrawLine(pen, i * (_placeSizeWidth + 30), j * _placeSizeHeight + 10, i * (_placeSizeWidth + 30) + _placeSizeWidth / 2, j * _placeSizeHeight + 10);
+                }
+                g.DrawLine(pen, i * (_placeSizeWidth + 30), 10, i * (_placeSizeWidth + 30), (_pictureHeight / _placeSizeHeight) * _placeSizeHeight + 10);
+            }
+        }
+        /// <summary>
+        /// Метод прорисовки объектов
+        /// </summary>
+        /// <param name="g"></param>
+        private void DrawLocomotives(Graphics g)
+        {
+            int x = 2;
+            int y = 10;
+            int countInRow = 0;
+            for (int i = 0; i < _setLocomotives.Count; i++)
+            {
+                if (countInRow >= _pictureWidth / _placeSizeWidth)
+                {
+                    x = 2;
+                    y += _placeSizeHeight;
+                    countInRow = 0;
+                }
+                if (_setLocomotives.Get(i) != null)
+                {
+                    var locomotive = _setLocomotives.Get(i);
+                    locomotive.SetObject(x, y, _pictureWidth, _pictureHeight);
+                    locomotive.DrawningObject(g);
+                    x += _placeSizeWidth + 30;
+                    countInRow++;
+                }
+            }
+        }
+    }
+}
diff --git a/WarmlyLocomotive/WarmlyLocomotive/Program.cs b/WarmlyLocomotive/WarmlyLocomotive/Program.cs
index f6449b7..5334215 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/Program.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/Program.cs
@@ -11,7 +11,7 @@ namespace WarmlyLocomotive
             // To customize application configuration such as set high DPI settings or default font,
             // see https://aka.ms/applicationconfiguration.
             ApplicationConfiguration.Initialize();
-            Application.Run(new FormMap());
+            Application.Run(new FormMapWithSetLocomotives());
         }
     }
 }
\ No newline at end of file
diff --git a/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs
new file mode 100644
index 0000000..156b343
--- /dev/null
+++ b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs
@@ -0,0 +1,143 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyLocomotive
+{
+    internal class SetLocomotivesGeneric<T>
+        where T : class
+    {
+        /// <summary>
+		/// Массив объектов, которые храним
+		/// </summary>
+		private readonly T[] _places;
+        /// <summary>
+        /// Количество объектов в массиве
+        /// </summary>
+        public int Count => _places.Length;
+        /// <summary>
+        /// Конструктор
+        /// </summary>
+        /// <param name="count"></param>
+        public SetLocomotivesGeneric(int count)
+        {
+            _places = new T[count];
+        }
+        /// <summary>
+        /// Добавление объекта в набор
+        /// </summary>
+        /// <param name="locomotive">Добавляемый локомотив</param>
+        /// <returns></returns>
+        public int Insert(T locomotive)
+        {
+            // TODO вставка в начало набора
+            bool hasEmptySpace = false;
+            int indexOfEmptyPlace = 0;
+            for (int i = 0; i < Count; ++i)
+            {
+                if (_places[i] == null || _places[i] == default(T))
+                {
+                    hasEmptySpace = true;
+                    indexOfEmptyPlace = i;
+                    break;
+                }
+            }
+            if (hasEmptySpace)
+            {
+                for (int i = indexOfEmptyPlace; i > 0; --i)
+                {
+                    _places[i] = _places[i - 1];
+                }
+                _places[0] = locomotive;
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        /// <summary>
+        /// Добавление объекта в набор на конкретную позицию
+        /// </summary>
+        /// <param name="car">Добавляемый локомотив</param>
+        /// <param name="position">Позиция</param>
+        /// <returns></returns>
+        public int Insert(T locomotive, int position)
+        {
+            // TODO проверка позиции
+            // TODO проверка, что элемент массива по этой позиции пустой, если нет, то
+            //		проверка, что после вставляемого элемента в массиве есть пустой элемент
+            //		сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
+            // TODO вставка по позиции
+            if (position < 0 || position >= Count)
+            {
+                return -1;
+            }
+            if (_places[position] == null || _places[position] == default(T))
+            {
+                _places[position] = locomotive;
+                return position;
+            }
+            else
+            {
+                bool hasEmptySpace = false;
+                int indexOfEmptyPlace = 0;
+                for (int i = position + 1; i < Count; ++i)
+                {
+                    if (_places[i] == null || _places[i] == default(T))
+                    {
+                        hasEmptySpace = true;
+                        indexOfEmptyPlace = i;
+                        break;
+                    }
+                }
+                if (hasEmptySpace)
+                {
+                    for (int i = indexOfEmptyPlace; i > position; --i)
+                    {
+                        _places[i] = _places[i - 1];
+                    }
+                    _places[position] = locomotive;
+                    return position;
+                }
+                else
+                {
+                    return -1;
+                }
+            }
+        }
+        /// <summary>
+        /// Удаление объекта из набора с конкретной позиции
+        /// </summary>
+        /// <param name="position"></param>
+        /// <returns></returns>
+        public T Remove(int position)
+        {
+            // TODO проверка позиции
+            // TODO удаление объекта из массива, присовив элементу массива значение null
+            if (position < 0 || position >= Count)
+            {
+                return null;
+            }
+            T memoryObj = _places[position];
+            _places[position] = null;
+            return memoryObj;
+        }
+        /// <summary>
+        /// Получение объекта из набора по позиции
+        /// </summary>
+        /// <param name="position"></param>
+        /// <returns></returns>
+        public T Get(int position)
+        {
+            // TODO проверка позиции
+            if (position < 0 || position >= Count)
+            {
+                return null;
+            }
+            return _places[position];
+        }
+    }
+}
-- 
2.25.1


From 33701833e921daafc886c9beb63c0afb15adb78b Mon Sep 17 00:00:00 2001
From: Danil Malin <malin-03@mail.ru>
Date: Sun, 9 Oct 2022 14:20:50 +0400
Subject: [PATCH 2/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?=
 =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?=
 =?UTF-8?q?=D0=B8=D0=B8=20=D0=B8=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE?=
 =?UTF-8?q?=D0=B2=D0=BA=D0=B5=20=D0=B4=D0=B5=D0=BF=D0=BE=20=D0=BB=D0=BE?=
 =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BE=D1=82=D0=B8=D0=B2=D0=BE=D0=B2.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../MapWithSetLocomotivesGeneric.cs           | 31 ++++++++++---------
 .../WarmlyLocomotive/SetLocomotivesGeneric.cs | 11 +------
 2 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
index aca2892..d5ddb84 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
@@ -25,7 +25,7 @@ namespace WarmlyLocomotive
         /// <summary>
         /// Размер занимаемого объектом места (высота)
         /// </summary>
-        private readonly int _placeSizeHeight = 120 /*105*/;
+        private readonly int _placeSizeHeight = 120;
         /// <summary>
         /// Набор объектов
         /// </summary>
@@ -149,19 +149,20 @@ namespace WarmlyLocomotive
             Brush brushLightGray = new SolidBrush(Color.LightGray);
             Brush brushBrown = new SolidBrush(Color.Brown);
             g.FillRectangle(brushLightGray, 0, 0, _pictureWidth, _pictureHeight);
-            for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+            int placesInRow = _pictureWidth / (_placeSizeWidth + 30);
+            for (int i = 0; i < placesInRow; i++)
             {
                 for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
                 {//линия рамзетки места
                     if (j != 0)
                     {
-                        int x = i * (_placeSizeWidth + 30);
-                        g.DrawLine(penTwo, x, j * _placeSizeHeight, x + _placeSizeWidth - 20, j * _placeSizeHeight);
-                        g.DrawLine(penTwo, x, j * _placeSizeHeight - 20, x + _placeSizeWidth - 20, j * _placeSizeHeight - 20);
+                        int xForRail = i * (_placeSizeWidth + 30);
+                        g.DrawLine(penTwo, xForRail, j * _placeSizeHeight, xForRail + _placeSizeWidth - 20, j * _placeSizeHeight);
+                        g.DrawLine(penTwo, xForRail, j * _placeSizeHeight - 20, xForRail + _placeSizeWidth - 20, j * _placeSizeHeight - 20);
                         for (int k = 0; k < (_placeSizeWidth - 20) / 15; ++k)
                         {
-                            g.FillRectangle(brushBrown, x, j * _placeSizeHeight - 20, 5, 20);
-                            x += 15;
+                            g.FillRectangle(brushBrown, xForRail, j * _placeSizeHeight - 20, 5, 20);
+                            xForRail += 15;
                         }
                     }
                     g.DrawLine(pen, i * (_placeSizeWidth + 30), j * _placeSizeHeight + 10, i * (_placeSizeWidth + 30) + _placeSizeWidth / 2, j * _placeSizeHeight + 10);
@@ -175,23 +176,23 @@ namespace WarmlyLocomotive
         /// <param name="g"></param>
         private void DrawLocomotives(Graphics g)
         {
-            int x = 2;
-            int y = 10;
+            int xForLocomotive = 2;
+            int yForLocomotive = 10;
             int countInRow = 0;
             for (int i = 0; i < _setLocomotives.Count; i++)
             {
-                if (countInRow >= _pictureWidth / _placeSizeWidth)
+                if (countInRow >= _pictureWidth / (_placeSizeWidth + 30))
                 {
-                    x = 2;
-                    y += _placeSizeHeight;
+                    xForLocomotive = 2;
+                    yForLocomotive += _placeSizeHeight;
                     countInRow = 0;
                 }
                 if (_setLocomotives.Get(i) != null)
                 {
-                    var locomotive = _setLocomotives.Get(i);
-                    locomotive.SetObject(x, y, _pictureWidth, _pictureHeight);
+                    T locomotive = _setLocomotives.Get(i);
+                    locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight);
                     locomotive.DrawningObject(g);
-                    x += _placeSizeWidth + 30;
+                    xForLocomotive += _placeSizeWidth + 30;
                     countInRow++;
                 }
             }
diff --git a/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs
index 156b343..eec3dba 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs
@@ -32,7 +32,6 @@ namespace WarmlyLocomotive
         /// <returns></returns>
         public int Insert(T locomotive)
         {
-            // TODO вставка в начало набора
             bool hasEmptySpace = false;
             int indexOfEmptyPlace = 0;
             for (int i = 0; i < Count; ++i)
@@ -61,16 +60,11 @@ namespace WarmlyLocomotive
         /// <summary>
         /// Добавление объекта в набор на конкретную позицию
         /// </summary>
-        /// <param name="car">Добавляемый локомотив</param>
+        /// <param name="locomotive">Добавляемый локомотив</param>
         /// <param name="position">Позиция</param>
         /// <returns></returns>
         public int Insert(T locomotive, int position)
         {
-            // TODO проверка позиции
-            // TODO проверка, что элемент массива по этой позиции пустой, если нет, то
-            //		проверка, что после вставляемого элемента в массиве есть пустой элемент
-            //		сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
-            // TODO вставка по позиции
             if (position < 0 || position >= Count)
             {
                 return -1;
@@ -115,8 +109,6 @@ namespace WarmlyLocomotive
         /// <returns></returns>
         public T Remove(int position)
         {
-            // TODO проверка позиции
-            // TODO удаление объекта из массива, присовив элементу массива значение null
             if (position < 0 || position >= Count)
             {
                 return null;
@@ -132,7 +124,6 @@ namespace WarmlyLocomotive
         /// <returns></returns>
         public T Get(int position)
         {
-            // TODO проверка позиции
             if (position < 0 || position >= Count)
             {
                 return null;
-- 
2.25.1


From e672312abc6e1f11c0b1ae951f8ced8f403c312a Mon Sep 17 00:00:00 2001
From: Danil Malin <malin-03@mail.ru>
Date: Tue, 11 Oct 2022 12:19:17 +0400
Subject: [PATCH 3/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D1=87?=
 =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=B1=D0=B0=D0=B3=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs         | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
index d5ddb84..ef79607 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
@@ -192,9 +192,10 @@ namespace WarmlyLocomotive
                     T locomotive = _setLocomotives.Get(i);
                     locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight);
                     locomotive.DrawningObject(g);
-                    xForLocomotive += _placeSizeWidth + 30;
-                    countInRow++;
+                   
                 }
+                xForLocomotive += _placeSizeWidth + 30;
+                countInRow++;
             }
         }
     }
-- 
2.25.1


From 50c261a24cf6b84497fc62f3531fe3b234cfa6e5 Mon Sep 17 00:00:00 2001
From: Danil Malin <malin-03@mail.ru>
Date: Tue, 11 Oct 2022 12:21:34 +0400
Subject: [PATCH 4/5] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?=
 =?UTF-8?q?=D0=B5=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9=20=D1=81=D1=82?=
 =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs             | 1 -
 1 file changed, 1 deletion(-)

diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
index ef79607..297daad 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs
@@ -192,7 +192,6 @@ namespace WarmlyLocomotive
                     T locomotive = _setLocomotives.Get(i);
                     locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight);
                     locomotive.DrawningObject(g);
-                   
                 }
                 xForLocomotive += _placeSizeWidth + 30;
                 countInRow++;
-- 
2.25.1


From 8380d8b6c4d8cd99f97bdc6d5ee6f3aa015a3848 Mon Sep 17 00:00:00 2001
From: Danil Malin <malin-03@mail.ru>
Date: Wed, 12 Oct 2022 23:05:43 +0400
Subject: [PATCH 5/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?=
 =?UTF-8?q?=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE?=
 =?UTF-8?q?=D0=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../WarmlyLocomotive/FormMapWithSetLocomotives.cs             | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
index f512cb6..9f1f729 100644
--- a/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
+++ b/WarmlyLocomotive/WarmlyLocomotive/FormMapWithSetLocomotives.cs
@@ -65,8 +65,8 @@ namespace WarmlyLocomotive
             FormLocomotive form = new();
             if (form.ShowDialog() == DialogResult.OK)
             {
-                DrawningObjectLocomotive car = new(form.SelectedLocomotive);
-                if (_mapLocomotivesCollectionGeneric + car != -1)
+                DrawningObjectLocomotive locomotive = new(form.SelectedLocomotive);
+                if (_mapLocomotivesCollectionGeneric + locomotive != -1)
                 {
                     MessageBox.Show("Объект добавлен");
                     pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
-- 
2.25.1