diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.Designer.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.Designer.cs
deleted file mode 100644
index 1e97595..0000000
--- a/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace ProjectAircraftCarrier
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.cs
deleted file mode 100644
index f1a07ae..0000000
--- a/ProjectAircraftCarrier/ProjectAircraftCarrier/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ProjectAircraftCarrier
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/ProjectAircraftCarrier.csproj b/ProjectAircraftCarrier/ProjectAircraftCarrier/ProjectAircraftCarrier.csproj
deleted file mode 100644
index 663fdb8..0000000
--- a/ProjectAircraftCarrier/ProjectAircraftCarrier/ProjectAircraftCarrier.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net8.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier.sln b/ProjectAircraftCarrier_/ProjectAircraftCarrier_.sln
similarity index 59%
rename from ProjectAircraftCarrier/ProjectAircraftCarrier.sln
rename to ProjectAircraftCarrier_/ProjectAircraftCarrier_.sln
index eaafb37..6a256d3 100644
--- a/ProjectAircraftCarrier/ProjectAircraftCarrier.sln
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
-VisualStudioVersion = 17.8.34525.116
+VisualStudioVersion = 17.8.34601.278
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectAircraftCarrier", "ProjectAircraftCarrier\ProjectAircraftCarrier.csproj", "{A871246D-86F2-4370-B644-24A99BFF6783}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectAircraftCarrier_", "ProjectAircraftCarrier_\ProjectAircraftCarrier_.csproj", "{9D47B714-02FD-4D16-8FD1-7CC43F92533E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {A871246D-86F2-4370-B644-24A99BFF6783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A871246D-86F2-4370-B644-24A99BFF6783}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A871246D-86F2-4370-B644-24A99BFF6783}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A871246D-86F2-4370-B644-24A99BFF6783}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9D47B714-02FD-4D16-8FD1-7CC43F92533E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9D47B714-02FD-4D16-8FD1-7CC43F92533E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9D47B714-02FD-4D16-8FD1-7CC43F92533E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9D47B714-02FD-4D16-8FD1-7CC43F92533E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {7F4937DC-FEE0-4D3B-8062-6479A5B07CE4}
+ SolutionGuid = {0384B21C-1A79-4855-A419-87A2504E0670}
EndGlobalSection
EndGlobal
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs
new file mode 100644
index 0000000..377357a
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs
@@ -0,0 +1,116 @@
+using ProjectAircraftCarrier_.Drawnings;
+
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Абстракция компании, хранящий коллекцию автомобилей
+///
+public abstract class AbstractCompany
+{
+ ///
+ /// Размер места (ширина)
+ ///
+ protected readonly int _placeSizeWidth = 300;
+
+ ///
+ /// Размер места (высота)
+ ///
+ protected readonly int _placeSizeHeight = 80;
+
+ ///
+ /// Ширина окна
+ ///
+ protected readonly int _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ protected readonly int _pictureHeight;
+
+ ///
+ /// Коллекция автомобилей
+ ///
+ protected ICollectionGenericObjects? _collection = null;
+
+ ///
+ /// Вычисление максимального количества элементов, который можно разместить в окне
+ ///
+ private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
+
+ ///
+ /// Конструктор
+ ///
+ /// Ширина окна
+ /// Высота окна
+ /// Коллекция автомобилей
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection)
+ {
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = collection;
+ _collection.SetMaxCount = GetMaxCount;
+ }
+
+ ///
+ /// Перегрузка оператора сложения для класса
+ ///
+ /// Компания
+ /// Добавляемый объект
+ ///
+ public static int operator +(AbstractCompany company, DrawningWarship warship)
+ {
+ return company._collection.Insert(warship, 0);
+ }
+
+ ///
+ /// Перегрузка оператора удаления для класса
+ ///
+ /// Компания
+ /// Номер удаляемого объекта
+ ///
+ public static DrawningWarship? operator -(AbstractCompany company, int position)
+ {
+ return company._collection?.Remove(position);
+ }
+
+ ///
+ /// Получение случайного объекта из коллекции
+ ///
+ ///
+ public DrawningWarship? GetRandomObject()
+ {
+ Random rnd = new();
+ return _collection?.Get(rnd.Next(GetMaxCount));
+ }
+
+ ///
+ /// Вывод всей коллекции
+ ///
+ ///
+ public Bitmap? Show()
+ {
+ Bitmap bitmap = new(_pictureWidth, _pictureHeight);
+ Graphics graphics = Graphics.FromImage(bitmap);
+ DrawBackground(graphics);
+
+ SetObjectsPosition();
+ for (int i = 0; i < (_collection?.Count ?? 0); ++i)
+ {
+ DrawningWarship? obj = _collection?.Get(i);
+ obj?.DrawTransport(graphics);
+ }
+
+ return bitmap;
+ }
+
+ ///
+ /// Вывод заднего фона
+ ///
+ ///
+ protected abstract void DrawBackground(Graphics g);
+
+ ///
+ /// Расстановка объектов
+ ///
+ protected abstract void SetObjectsPosition();
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/CollectionType.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/CollectionType.cs
new file mode 100644
index 0000000..2110f55
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/CollectionType.cs
@@ -0,0 +1,22 @@
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Тип коллекции
+///
+public enum CollectionType
+{
+ ///
+ /// Неопределено
+ ///
+ None = 0,
+
+ ///
+ /// Массив
+ ///
+ Massive = 1,
+
+ ///
+ /// Список
+ ///
+ List = 2
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs
new file mode 100644
index 0000000..44ab95c
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs
@@ -0,0 +1,61 @@
+
+using ProjectAircraftCarrier_.Drawnings;
+
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+public class Docks : AbstractCompany
+{
+ public Docks(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ {
+ }
+
+ protected override void DrawBackground(Graphics g)
+ {
+ Pen pen = new(Color.Black, 2);
+ Pen widerPen = new(Color.Black, 5);
+
+ for (int i = 0; i < _pictureHeight / _placeSizeHeight; i++)
+ {
+ int y = _placeSizeHeight;
+ y *= i;
+
+ for (int j = 0; j <= _pictureWidth / _placeSizeWidth; j++)
+ {
+ int x = _placeSizeWidth;
+ x *= j;
+
+ g.DrawLine(widerPen, x, y, x + _placeSizeWidth / 2, y);
+ g.DrawLine(widerPen, x, y + _placeSizeHeight - 10, x + _placeSizeWidth / 2, y + _placeSizeHeight - 10);
+ g.DrawLine(pen, x, y, x, y + _placeSizeHeight - 10);
+ g.DrawLine(pen, x + _placeSizeWidth / 2, y, x + _placeSizeWidth / 2, y + _placeSizeHeight - 10);
+ }
+
+ }
+ }
+
+ protected override void SetObjectsPosition()
+ {
+ int n = 0;
+ int m = 0;
+
+ for (int i = 0; i < (_collection?.Count ?? 0); i++)
+ {
+ if (_collection?.Get(i) != null)
+ {
+ int x = 5 + _placeSizeWidth * n;
+ int y = (10 + _placeSizeHeight * (_pictureHeight / _placeSizeHeight - 1)) - _placeSizeHeight * m;
+
+ _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
+ _collection?.Get(i)?.SetPosition(x, y);
+ }
+
+ if (n < _pictureWidth / _placeSizeWidth)
+ n++;
+ else
+ {
+ n = 0;
+ m++;
+ }
+ }
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs
new file mode 100644
index 0000000..d193837
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -0,0 +1,49 @@
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Интерфейс описания действий для набора хранимых объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public interface ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Количество объектов в коллекции
+ ///
+ int Count { get; }
+
+ ///
+ /// Установка максимального количества элементов
+ ///
+ int SetMaxCount { set; }
+
+ ///
+ /// Добавление объекта в коллекцию
+ ///
+ /// Добавляемый объект
+ /// индекс добавленного элемента - вставка прошла удачно, -1 - вставка не удалась
+ int Insert(T obj);
+
+ ///
+ /// Добавление объекта в коллекцию на конкретную позицию
+ ///
+ /// Добавляемый объект
+ /// Позиция
+ /// индекс добавленного элемента - вставка прошла удачно, -1 - вставка не удалась
+ int Insert(T obj, int position);
+
+ ///
+ /// Удаление объекта из коллекции с конкретной позиции
+ ///
+ /// Позиция
+ /// удаленный объект - удаление прошло удачно, null - удаление не удалось
+ T? Remove(int position);
+
+ ///
+ /// Получение объекта по позиции
+ ///
+ /// Позиция
+ /// Объект
+ T? Get(int position);
+}
+
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ListGenericObject.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ListGenericObject.cs
new file mode 100644
index 0000000..565ec2d
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ListGenericObject.cs
@@ -0,0 +1,78 @@
+using System.CodeDom.Compiler;
+
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class ListGenericObject : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Список объектов, которые храним
+ ///
+ private readonly List _collection;
+
+ ///
+ /// Максимально допустимое число объектов в списке
+ ///
+ private int _maxCount;
+
+ public int Count => _collection.Count;
+
+ public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+
+ ///
+ /// Конструктор
+ ///
+ public ListGenericObject()
+ {
+ _collection = new();
+ }
+
+ public T? Get(int position)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return null;
+ }
+
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ if (Count == _maxCount)
+ {
+ return -1;
+ }
+
+ _collection.Add(obj);
+ return _collection.Count;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (Count == _maxCount || position < 0 || position > Count)
+ {
+ return -1;
+ }
+
+ _collection.Insert(position, obj);
+ return position;
+ }
+
+ public T? Remove(int position)
+ {
+ if (position < 0 || position > Count)
+ {
+ return null;
+ }
+
+ T? obj = _collection[position];
+ _collection.RemoveAt(position);
+
+ return obj;
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs
new file mode 100644
index 0000000..851a207
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -0,0 +1,111 @@
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Параметризованный набор объектов
+///
+/// Параметр: ограничение - ссылочный тип
+public class MassiveGenericObjects : ICollectionGenericObjects
+ where T : class
+{
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private T?[] _collection;
+
+ public int Count => _collection.Length;
+
+ public int SetMaxCount
+ {
+ set
+ {
+ if (value > 0)
+ {
+ if (_collection.Length > 0)
+ {
+ Array.Resize(ref _collection, value);
+ }
+ else
+ {
+ _collection = new T?[value];
+ }
+ }
+ }
+ }
+
+ ///
+ /// Конструктор
+ ///
+ public MassiveGenericObjects()
+ {
+ _collection = Array.Empty();
+ }
+
+ public T? Get(int position)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return null;
+ }
+ return _collection[position];
+ }
+
+ public int Insert(T obj)
+ {
+ for (int i = 0; i < Count; i++)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int Insert(T obj, int position)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return -1;
+ }
+
+ if (_collection[position] == null)
+ {
+ _collection[position] = obj;
+ return position;
+ }
+
+ for (int i = position + 1; i < Count; i++)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+
+ for (int i = position - 1; i >= 0; i--)
+ {
+ if (_collection[i] == null)
+ {
+ _collection[i] = obj;
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ public T? Remove(int position)
+ {
+ if (position < 0 || position >= Count || _collection[position] == null)
+ {
+ return null;
+ }
+
+ T? obj = _collection[position];
+ _collection[position] = null;
+ return obj;
+ }
+}
+
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/StorageCollection.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/StorageCollection.cs
new file mode 100644
index 0000000..e49e591
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/StorageCollection.cs
@@ -0,0 +1,86 @@
+using ProjectAircraftCarrier_.Drawnings;
+using ProjectAircraftCarrier_.CollectionGenericObjects;
+using System.Xml.Linq;
+
+namespace ProjectAircraftCarrier_.CollectionGenericObjects;
+
+///
+/// Класс-хранилище коллекций
+///
+///
+public class StorageCollection
+ where T : class
+{
+ ///
+ /// Словарь (хранилище) с коллекциями
+ ///
+ readonly Dictionary> _storages;
+
+ ///
+ /// Возвращение списка названий коллекций
+ ///
+ public List Keys => _storages.Keys.ToList();
+
+ ///
+ /// Конструктор
+ ///
+ public StorageCollection()
+ {
+ _storages = new Dictionary>();
+ }
+
+ ///
+ /// Добавление коллекции в хранилище
+ ///
+ /// Название коллекции
+ /// Тип коллекции
+ public void AddCollection(string name, CollectionType collectionType)
+ {
+ if (name == null || _storages.ContainsKey(name))
+ {
+ return;
+ }
+
+ if (collectionType == CollectionType.Massive)
+ {
+ _storages.Add(name, new MassiveGenericObjects());
+ }
+
+ if (collectionType == CollectionType.List)
+ {
+ _storages.Add(name, new ListGenericObject());
+ }
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ /// Название коллекции
+ public void DelCollection(string name)
+ {
+ if (name == null || !_storages.ContainsKey(name))
+ {
+ return;
+ }
+
+ _storages.Remove(name);
+ }
+
+ ///
+ /// Доступ к коллекции
+ ///
+ /// Название коллекции
+ ///
+ public ICollectionGenericObjects? this[string name]
+ {
+ get
+ {
+ if (_storages.ContainsKey(name))
+ {
+ return _storages[name];
+ }
+
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DirectionType.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DirectionType.cs
new file mode 100644
index 0000000..8378f93
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DirectionType.cs
@@ -0,0 +1,32 @@
+namespace ProjectAircraftCarrier_.Drawnings;
+
+///
+/// Направление перемещения
+///
+public enum DirectionType
+{
+ ///
+ /// Неизвестное направление
+ ///
+ Unknow = -1,
+
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+
+ ///
+ /// Влево
+ ///
+ Left = 3,
+
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningAircraftCarrier.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningAircraftCarrier.cs
new file mode 100644
index 0000000..35de8bf
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningAircraftCarrier.cs
@@ -0,0 +1,74 @@
+using ProjectAircraftCarrier_.Entities;
+
+namespace ProjectAircraftCarrier_.Drawnings;
+
+///
+/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningAircraftCarrier : DrawningWarship
+{
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Палуба для взлета самолетов
+ /// Рубка управления
+ /// Истребитель
+ public DrawningAircraftCarrier(int speed, double weight, Color bodyColor, Color additionalColor, bool deckForAircraftTakeOff, bool controlCabin, bool fighterJet) : base(140, 50)
+ {
+ EntityWarship = new EntityAircraftCarrier(speed, weight, bodyColor, additionalColor, deckForAircraftTakeOff, controlCabin, fighterJet);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntityWarship == null || EntityWarship is not EntityAircraftCarrier aircraftCarrier || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush additionalBrush = new SolidBrush(aircraftCarrier.AdditionalColor);
+ Pen additionalPen = new(aircraftCarrier.AdditionalColor, 2);
+
+ base.DrawTransport(g);
+
+ // Палуба для взлёта самолётов
+ if (aircraftCarrier.DeckForAircraftTakeOff)
+ {
+ Pen penYellow = new(Color.Yellow);
+
+ Point[] addPoints =
+ {
+ new Point(_startPosX.Value + 5, _startPosY.Value + 10),
+ new Point(_startPosX.Value + 105, _startPosY.Value),
+ new Point(_startPosX.Value + 120, _startPosY.Value + 15),
+ new Point(_startPosX.Value + 5, _startPosY.Value + 30),
+
+ };
+ g.DrawPolygon(pen, addPoints);
+ g.FillPolygon(additionalBrush, addPoints);
+ // Разметка
+ g.DrawLine(penYellow, _startPosX.Value + 10, _startPosY.Value + 20, _startPosX.Value + 105, _startPosY.Value + 8);
+ }
+
+ // Рубка
+ if (aircraftCarrier.ControlCabin)
+ {
+ g.DrawEllipse(pen, _startPosX.Value + 40, _startPosY.Value + 35, 30, 10);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 35, 30, 10);
+ }
+
+ // Истребитель
+ if (aircraftCarrier.FighterJet)
+ {
+ g.DrawLine(additionalPen, _startPosX.Value + 95, _startPosY.Value + 27, _startPosX.Value + 95, _startPosY.Value + 47);
+ g.DrawLine(additionalPen, _startPosX.Value + 85, _startPosY.Value + 42, _startPosX.Value + 95, _startPosY.Value + 32);
+ g.DrawLine(additionalPen, _startPosX.Value + 95, _startPosY.Value + 32, _startPosX.Value + 105, _startPosY.Value + 42);
+ g.DrawLine(additionalPen, _startPosX.Value + 90, _startPosY.Value + 46, _startPosX.Value + 95, _startPosY.Value + 41);
+ g.DrawLine(additionalPen, _startPosX.Value + 95, _startPosY.Value + 41, _startPosX.Value + 100, _startPosY.Value + 46);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningWarship.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningWarship.cs
new file mode 100644
index 0000000..c1c8114
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Drawnings/DrawningWarship.cs
@@ -0,0 +1,248 @@
+using ProjectAircraftCarrier_.Entities;
+
+namespace ProjectAircraftCarrier_.Drawnings;
+
+///
+/// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности
+///
+public class DrawningWarship
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityWarship? EntityWarship { get; protected set; }
+
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+
+ ///
+ /// Левая координата прорисовки военного корабля
+ ///
+ protected int? _startPosX;
+
+ ///
+ /// Верхняя координата прорисовки военного корабля
+ ///
+ protected int? _startPosY;
+
+ ///
+ /// Ширина прорисовки военного корабля
+ ///
+ private readonly int _drawningWarshipWidth = 140;
+
+ ///
+ /// Высота прорисовки военного корабля
+ ///
+ private readonly int _drawningWarshipHeight = 50;
+
+ ///
+ /// Координата X объекта
+ ///
+ public int? GetPosX => _startPosX;
+
+ ///
+ /// Координата Y объекта
+ ///
+ public int? GetPosY => _startPosY;
+
+ ///
+ /// Ширина объекта
+ ///
+ public int GetWidth => _drawningWarshipWidth;
+
+ ///
+ /// Высота объекта
+ ///
+ public int GetHeight => _drawningWarshipHeight;
+
+ ///
+ /// Пустой конструктор
+ ///
+ private DrawningWarship()
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningWarship(int speed, double weight, Color bodyColor) : this()
+ {
+ EntityWarship = new EntityWarship(speed, weight, bodyColor);
+ }
+
+ ///
+ /// Конструктор для наследников
+ ///
+ /// Ширина прорисовки военного корабля
+ /// Высота прорисовки военного корабля
+ protected DrawningWarship(int DrawningWarshiprierWidth, int DrawningWarshiprierHeight) : this()
+ {
+ _drawningWarshipWidth = DrawningWarshiprierWidth;
+ _drawningWarshipHeight = DrawningWarshiprierHeight;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+ if (_drawningWarshipWidth <= width && _drawningWarshipHeight <= height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_startPosX.HasValue && _startPosY.HasValue)
+ {
+ if (_startPosX + _drawningWarshipWidth > width)
+ {
+ _startPosX = width - _drawningWarshipWidth;
+ }
+
+ if (_startPosY + _drawningWarshipHeight > height)
+ {
+ _startPosY = height - _drawningWarshipHeight;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+
+ _startPosX = x;
+ _startPosY = y;
+ if (x < 0)
+ {
+ _startPosX = 0;
+ }
+
+ if (y < 0)
+ {
+ _startPosY = 0;
+ }
+
+ if (x + _drawningWarshipWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _drawningWarshipWidth;
+ }
+
+ if (y + _drawningWarshipHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _drawningWarshipHeight;
+ }
+ }
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение невозможно
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityWarship == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+
+ switch (direction)
+ {
+ // Влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityWarship.Step > 0)
+ {
+ _startPosX -= (int)EntityWarship.Step;
+ }
+ return true;
+ // Вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityWarship.Step > 0)
+ {
+ _startPosY -= (int)EntityWarship.Step;
+ }
+ return true;
+ // Вправо
+ case DirectionType.Right:
+ if (_startPosX.Value + _drawningWarshipWidth + EntityWarship.Step < _pictureWidth.Value)
+ {
+ _startPosX += (int)EntityWarship.Step;
+ }
+ return true;
+ // Вниз
+ case DirectionType.Down:
+ if (_startPosY.Value + _drawningWarshipHeight + EntityWarship.Step < _pictureHeight.Value)
+ {
+ _startPosY += (int)EntityWarship.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public virtual void DrawTransport(Graphics g)
+ {
+ if (EntityWarship == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+
+ // Границы перевозчика
+ g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value, 100, 50);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 5, 5, 15);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 30, 5, 15);
+
+ Point[] points =
+ {
+ new Point(_startPosX.Value + 105, _startPosY.Value),
+ new Point(_startPosX.Value + 120, _startPosY.Value + 15),
+ new Point(_startPosX.Value + 140, _startPosY.Value + 20),
+ new Point(_startPosX.Value + 140, _startPosY.Value + 30),
+ new Point(_startPosX.Value + 120, _startPosY.Value + 35),
+ new Point(_startPosX.Value + 105, _startPosY.Value + 50),
+
+ };
+ g.DrawPolygon(pen, points);
+
+ // Палуба
+ Brush br = new SolidBrush(EntityWarship.BodyColor);
+ Brush brBlack = new SolidBrush(Color.Black);
+ g.FillRectangle(br, _startPosX.Value + 6, _startPosY.Value + 1, 100, 49);
+ g.FillPolygon(br, points);
+ g.FillRectangle(brBlack, _startPosX.Value, _startPosY.Value + 5, 5, 15);
+ g.FillRectangle(brBlack, _startPosX.Value, _startPosY.Value + 30, 5, 15);
+ }
+
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityAircraftCarrier.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityAircraftCarrier.cs
new file mode 100644
index 0000000..77ed170
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityAircraftCarrier.cs
@@ -0,0 +1,45 @@
+namespace ProjectAircraftCarrier_.Entities;
+
+///
+/// Класс-сущность "Авианосец"
+///
+public class EntityAircraftCarrier : EntityWarship
+{
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+
+ ///
+ /// Признак (опция) наличия палубы для взлета самолетов
+ ///
+ public bool DeckForAircraftTakeOff { get; private set; }
+
+ ///
+ /// Признак (опция) наличия рубки управления
+ ///
+ public bool ControlCabin { get; private set; }
+
+ ///
+ /// Признак (опция) наличия истребителя
+ ///
+ public bool FighterJet { get; private set; }
+
+ ///
+ /// Инициализация полей объекта-класса авианосца
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Палуба для взлета самолетов
+ /// Признак наличия рубки управления
+ /// Признак наличия истребителя
+ public EntityAircraftCarrier(int speed, double weight, Color bodyColor, Color additionalColor, bool deckForAircraftTakeOff, bool controlCabin, bool fighterJet) : base(speed, weight, bodyColor)
+ {
+ AdditionalColor = additionalColor;
+ DeckForAircraftTakeOff = deckForAircraftTakeOff;
+ ControlCabin = controlCabin;
+ FighterJet = fighterJet;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityWarship.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityWarship.cs
new file mode 100644
index 0000000..461a100
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Entities/EntityWarship.cs
@@ -0,0 +1,41 @@
+namespace ProjectAircraftCarrier_.Entities;
+
+///
+/// Класс-сущность "Военный корабль"
+///
+public class EntityWarship
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Шаг перемещения военного корабля
+ ///
+ public double Step => Speed * 100 / Weight;
+
+ ///
+ /// Конструктор сущности
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public EntityWarship(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.Designer.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.Designer.cs
new file mode 100644
index 0000000..127533f
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.Designer.cs
@@ -0,0 +1,148 @@
+namespace ProjectAircraftCarrier_
+{
+ partial class FormAircraftCarrier
+ {
+ ///
+ /// 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()
+ {
+ pictureBoxAircraftCarrier = new PictureBox();
+ buttonLeft = new Button();
+ buttonDown = new Button();
+ buttonRight = new Button();
+ buttonUp = new Button();
+ comboBoxStrategy = new ComboBox();
+ buttonStrategyStep = new Button();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxAircraftCarrier).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxAircraftCarrier
+ //
+ pictureBoxAircraftCarrier.Dock = DockStyle.Fill;
+ pictureBoxAircraftCarrier.Location = new Point(0, 0);
+ pictureBoxAircraftCarrier.Name = "pictureBoxAircraftCarrier";
+ pictureBoxAircraftCarrier.Size = new Size(1392, 778);
+ pictureBoxAircraftCarrier.TabIndex = 0;
+ pictureBoxAircraftCarrier.TabStop = false;
+ //
+ // buttonLeft
+ //
+ buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
+ buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonLeft.Location = new Point(1255, 731);
+ buttonLeft.Name = "buttonLeft";
+ buttonLeft.Size = new Size(35, 35);
+ buttonLeft.TabIndex = 2;
+ buttonLeft.UseVisualStyleBackColor = true;
+ buttonLeft.Click += ButtonMove_Click;
+ //
+ // buttonDown
+ //
+ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonDown.BackgroundImage = Properties.Resources.arrowDown;
+ buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonDown.Location = new Point(1296, 731);
+ buttonDown.Name = "buttonDown";
+ buttonDown.Size = new Size(35, 35);
+ buttonDown.TabIndex = 3;
+ buttonDown.UseVisualStyleBackColor = true;
+ buttonDown.Click += ButtonMove_Click;
+ //
+ // buttonRight
+ //
+ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonRight.BackgroundImage = Properties.Resources.arrowRight;
+ buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonRight.Location = new Point(1337, 731);
+ buttonRight.Name = "buttonRight";
+ buttonRight.Size = new Size(35, 35);
+ buttonRight.TabIndex = 4;
+ buttonRight.UseVisualStyleBackColor = true;
+ buttonRight.Click += ButtonMove_Click;
+ //
+ // buttonUp
+ //
+ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonUp.BackgroundImage = Properties.Resources.arrowUp;
+ buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
+ buttonUp.Location = new Point(1296, 690);
+ buttonUp.Name = "buttonUp";
+ buttonUp.Size = new Size(35, 35);
+ buttonUp.TabIndex = 5;
+ buttonUp.UseVisualStyleBackColor = true;
+ buttonUp.Click += ButtonMove_Click;
+ //
+ // comboBoxStrategy
+ //
+ comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxStrategy.FormattingEnabled = true;
+ comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
+ comboBoxStrategy.Location = new Point(1168, 12);
+ comboBoxStrategy.Name = "comboBoxStrategy";
+ comboBoxStrategy.Size = new Size(212, 38);
+ comboBoxStrategy.TabIndex = 8;
+ //
+ // buttonStrategyStep
+ //
+ buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonStrategyStep.Location = new Point(1249, 56);
+ buttonStrategyStep.Name = "buttonStrategyStep";
+ buttonStrategyStep.Size = new Size(131, 40);
+ buttonStrategyStep.TabIndex = 9;
+ buttonStrategyStep.Text = "Шаг";
+ buttonStrategyStep.UseVisualStyleBackColor = true;
+ buttonStrategyStep.Click += ButtonStrategyStep_Click;
+ //
+ // FormAircraftCarrier
+ //
+ AutoScaleDimensions = new SizeF(12F, 30F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1392, 778);
+ Controls.Add(buttonStrategyStep);
+ Controls.Add(comboBoxStrategy);
+ Controls.Add(buttonUp);
+ Controls.Add(buttonRight);
+ Controls.Add(buttonDown);
+ Controls.Add(buttonLeft);
+ Controls.Add(pictureBoxAircraftCarrier);
+ Name = "FormAircraftCarrier";
+ Text = "Авианосец";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxAircraftCarrier).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxAircraftCarrier;
+ private Button buttonLeft;
+ private Button buttonDown;
+ private Button buttonRight;
+ private Button buttonUp;
+ private ComboBox comboBoxStrategy;
+ private Button buttonStrategyStep;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.cs
new file mode 100644
index 0000000..fb2c2ac
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.cs
@@ -0,0 +1,140 @@
+using ProjectAircraftCarrier_.Drawnings;
+using ProjectAircraftCarrier_.MovementStrategy;
+
+namespace ProjectAircraftCarrier_;
+
+///
+/// Форма работы с объектом "Авианосец"
+///
+public partial class FormAircraftCarrier : Form
+{
+ ///
+ /// Поле-объект для прорисовки объекта
+ ///
+ private DrawningWarship? _drawningWarship;
+
+ ///
+ /// Стратегия перемещения
+ ///
+ private AbstractStrategy? _strategy;
+
+ ///
+ /// Получение объекта
+ ///
+ public DrawningWarship SetWarship
+ {
+ set
+ {
+ _drawningWarship = value;
+ _drawningWarship.SetPictureSize(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ Draw();
+ }
+ }
+
+
+ ///
+ /// Конструктор формы
+ ///
+ public FormAircraftCarrier()
+ {
+ InitializeComponent();
+ _strategy = null;
+ }
+
+ ///
+ /// Метод прорисовки машины
+ ///
+ private void Draw()
+ {
+ if (_drawningWarship == null)
+ {
+ return;
+ }
+
+ Bitmap bmp = new(pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _drawningWarship.DrawTransport(gr);
+ pictureBoxAircraftCarrier.Image = bmp;
+ }
+
+ ///
+ /// Перемещение объекта по форме (нажатие кнопок навигации)
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_drawningWarship == null)
+ {
+ return;
+ }
+
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ bool result = false;
+ switch (name)
+ {
+ case "buttonUp":
+ result = _drawningWarship.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ result = _drawningWarship.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ result = _drawningWarship.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ result = _drawningWarship.MoveTransport(DirectionType.Right);
+ break;
+ }
+
+ if (result)
+ {
+ Draw();
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void ButtonStrategyStep_Click(object sender, EventArgs e)
+ {
+ if (_drawningWarship == null)
+ {
+ return;
+ }
+
+ if (comboBoxStrategy.Enabled)
+ {
+ _strategy = comboBoxStrategy.SelectedIndex switch
+ {
+ 0 => new MoveToCenter(),
+ 1 => new MoveToBorder(),
+ _ => null,
+ };
+ if (_strategy == null)
+ {
+ return;
+ }
+ _strategy.SetData(new MoveableWarship(_drawningWarship), pictureBoxAircraftCarrier.Width, pictureBoxAircraftCarrier.Height);
+ }
+
+ if (_strategy == null)
+ {
+ return;
+ }
+
+ comboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
+ Draw();
+
+ if (_strategy.GetStatus() == StrategyStatus.Finish)
+ {
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ }
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.resx b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormAircraftCarrier.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/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.Designer.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.Designer.cs
new file mode 100644
index 0000000..c977f39
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.Designer.cs
@@ -0,0 +1,302 @@
+namespace ProjectAircraftCarrier_
+{
+ partial class FormWarshipCollection
+ {
+ ///
+ /// 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()
+ {
+ groupBoxTools = new GroupBox();
+ panelCompanyTools = new Panel();
+ buttonAddAircraftCarrier = new Button();
+ buttonAddWarship = new Button();
+ maskedTextBoxPosition = new MaskedTextBox();
+ buttonRefresh = new Button();
+ buttonRemoveWarship = new Button();
+ buttonGoToCheck = new Button();
+ buttonCreateCompany = new Button();
+ panelStorage = new Panel();
+ buttonCollectionDel = new Button();
+ listBoxCollection = new ListBox();
+ buttonCollectionAdd = new Button();
+ radioButtonList = new RadioButton();
+ radioButtonMassive = new RadioButton();
+ textBoxCollectionName = new TextBox();
+ labelCollectionName = new Label();
+ comboBoxSelectorCompany = new ComboBox();
+ pictureBox = new PictureBox();
+ groupBoxTools.SuspendLayout();
+ panelCompanyTools.SuspendLayout();
+ panelStorage.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ groupBoxTools.Controls.Add(panelCompanyTools);
+ groupBoxTools.Controls.Add(buttonCreateCompany);
+ groupBoxTools.Controls.Add(panelStorage);
+ groupBoxTools.Controls.Add(comboBoxSelectorCompany);
+ groupBoxTools.Dock = DockStyle.Right;
+ groupBoxTools.Location = new Point(1176, 0);
+ groupBoxTools.Name = "groupBoxTools";
+ groupBoxTools.Size = new Size(326, 961);
+ groupBoxTools.TabIndex = 0;
+ groupBoxTools.TabStop = false;
+ groupBoxTools.Text = "Инструменты";
+ //
+ // panelCompanyTools
+ //
+ panelCompanyTools.Controls.Add(buttonAddAircraftCarrier);
+ panelCompanyTools.Controls.Add(buttonAddWarship);
+ panelCompanyTools.Controls.Add(maskedTextBoxPosition);
+ panelCompanyTools.Controls.Add(buttonRefresh);
+ panelCompanyTools.Controls.Add(buttonRemoveWarship);
+ panelCompanyTools.Controls.Add(buttonGoToCheck);
+ panelCompanyTools.Dock = DockStyle.Bottom;
+ panelCompanyTools.Enabled = false;
+ panelCompanyTools.Location = new Point(3, 529);
+ panelCompanyTools.Name = "panelCompanyTools";
+ panelCompanyTools.Size = new Size(320, 429);
+ panelCompanyTools.TabIndex = 9;
+ //
+ // buttonAddAircraftCarrier
+ //
+ buttonAddAircraftCarrier.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddAircraftCarrier.Location = new Point(3, 81);
+ buttonAddAircraftCarrier.Name = "buttonAddAircraftCarrier";
+ buttonAddAircraftCarrier.Size = new Size(314, 72);
+ buttonAddAircraftCarrier.TabIndex = 2;
+ buttonAddAircraftCarrier.Text = "Добавление авианосца";
+ buttonAddAircraftCarrier.UseVisualStyleBackColor = true;
+ buttonAddAircraftCarrier.Click += ButtonAddAircraftCarrier_Click;
+ //
+ // buttonAddWarship
+ //
+ buttonAddWarship.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonAddWarship.Location = new Point(3, 3);
+ buttonAddWarship.Name = "buttonAddWarship";
+ buttonAddWarship.Size = new Size(314, 72);
+ buttonAddWarship.TabIndex = 1;
+ buttonAddWarship.Text = "Добавление военного корабля";
+ buttonAddWarship.UseVisualStyleBackColor = true;
+ buttonAddWarship.Click += ButtonAddWarship_Click;
+ //
+ // maskedTextBoxPosition
+ //
+ maskedTextBoxPosition.Location = new Point(3, 159);
+ maskedTextBoxPosition.Mask = "00";
+ maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ maskedTextBoxPosition.Size = new Size(314, 35);
+ maskedTextBoxPosition.TabIndex = 3;
+ maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonRefresh
+ //
+ buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRefresh.Location = new Point(3, 356);
+ buttonRefresh.Name = "buttonRefresh";
+ buttonRefresh.Size = new Size(314, 72);
+ buttonRefresh.TabIndex = 6;
+ buttonRefresh.Text = "Обновить";
+ buttonRefresh.UseVisualStyleBackColor = true;
+ buttonRefresh.Click += ButtonRefresh_Click;
+ //
+ // buttonRemoveWarship
+ //
+ buttonRemoveWarship.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonRemoveWarship.Location = new Point(3, 200);
+ buttonRemoveWarship.Name = "buttonRemoveWarship";
+ buttonRemoveWarship.Size = new Size(314, 72);
+ buttonRemoveWarship.TabIndex = 4;
+ buttonRemoveWarship.Text = "Удаление военного корабля";
+ buttonRemoveWarship.UseVisualStyleBackColor = true;
+ buttonRemoveWarship.Click += ButtonRemoveWarship_Click;
+ //
+ // buttonGoToCheck
+ //
+ buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ buttonGoToCheck.Location = new Point(3, 278);
+ buttonGoToCheck.Name = "buttonGoToCheck";
+ buttonGoToCheck.Size = new Size(314, 72);
+ buttonGoToCheck.TabIndex = 5;
+ buttonGoToCheck.Text = "Передать на тесты";
+ buttonGoToCheck.UseVisualStyleBackColor = true;
+ buttonGoToCheck.Click += ButtonGoToCheck_Click;
+ //
+ // buttonCreateCompany
+ //
+ buttonCreateCompany.Location = new Point(6, 472);
+ buttonCreateCompany.Name = "buttonCreateCompany";
+ buttonCreateCompany.Size = new Size(314, 40);
+ buttonCreateCompany.TabIndex = 8;
+ buttonCreateCompany.Text = "Создать компанию";
+ buttonCreateCompany.UseVisualStyleBackColor = true;
+ buttonCreateCompany.Click += ButtonCreateCompany_Click;
+ //
+ // panelStorage
+ //
+ panelStorage.Controls.Add(buttonCollectionDel);
+ panelStorage.Controls.Add(listBoxCollection);
+ panelStorage.Controls.Add(buttonCollectionAdd);
+ panelStorage.Controls.Add(radioButtonList);
+ panelStorage.Controls.Add(radioButtonMassive);
+ panelStorage.Controls.Add(textBoxCollectionName);
+ panelStorage.Controls.Add(labelCollectionName);
+ panelStorage.Dock = DockStyle.Top;
+ panelStorage.Location = new Point(3, 31);
+ panelStorage.Name = "panelStorage";
+ panelStorage.Size = new Size(320, 382);
+ panelStorage.TabIndex = 7;
+ //
+ // buttonCollectionDel
+ //
+ buttonCollectionDel.Location = new Point(3, 331);
+ buttonCollectionDel.Name = "buttonCollectionDel";
+ buttonCollectionDel.Size = new Size(314, 40);
+ buttonCollectionDel.TabIndex = 6;
+ buttonCollectionDel.Text = "Удалить коллекцию";
+ buttonCollectionDel.UseVisualStyleBackColor = true;
+ buttonCollectionDel.Click += ButtonCollectionDel_Click;
+ //
+ // listBoxCollection
+ //
+ listBoxCollection.FormattingEnabled = true;
+ listBoxCollection.ItemHeight = 30;
+ listBoxCollection.Location = new Point(3, 171);
+ listBoxCollection.Name = "listBoxCollection";
+ listBoxCollection.Size = new Size(314, 154);
+ listBoxCollection.TabIndex = 5;
+ //
+ // buttonCollectionAdd
+ //
+ buttonCollectionAdd.Location = new Point(3, 125);
+ buttonCollectionAdd.Name = "buttonCollectionAdd";
+ buttonCollectionAdd.Size = new Size(314, 40);
+ buttonCollectionAdd.TabIndex = 4;
+ buttonCollectionAdd.Text = "Добавить коллекцию";
+ buttonCollectionAdd.UseVisualStyleBackColor = true;
+ buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
+ //
+ // radioButtonList
+ //
+ radioButtonList.AutoSize = true;
+ radioButtonList.Location = new Point(193, 85);
+ radioButtonList.Name = "radioButtonList";
+ radioButtonList.Size = new Size(107, 34);
+ radioButtonList.TabIndex = 3;
+ radioButtonList.TabStop = true;
+ radioButtonList.Text = "Список";
+ radioButtonList.UseVisualStyleBackColor = true;
+ //
+ // radioButtonMassive
+ //
+ radioButtonMassive.AutoSize = true;
+ radioButtonMassive.Location = new Point(23, 85);
+ radioButtonMassive.Name = "radioButtonMassive";
+ radioButtonMassive.Size = new Size(111, 34);
+ radioButtonMassive.TabIndex = 2;
+ radioButtonMassive.TabStop = true;
+ radioButtonMassive.Text = "Массив";
+ radioButtonMassive.UseVisualStyleBackColor = true;
+ //
+ // textBoxCollectionName
+ //
+ textBoxCollectionName.Location = new Point(3, 44);
+ textBoxCollectionName.Name = "textBoxCollectionName";
+ textBoxCollectionName.Size = new Size(314, 35);
+ textBoxCollectionName.TabIndex = 1;
+ //
+ // labelCollectionName
+ //
+ labelCollectionName.AutoSize = true;
+ labelCollectionName.Location = new Point(58, 11);
+ labelCollectionName.Name = "labelCollectionName";
+ labelCollectionName.Size = new Size(213, 30);
+ labelCollectionName.TabIndex = 0;
+ labelCollectionName.Text = "Название коллекции";
+ //
+ // comboBoxSelectorCompany
+ //
+ comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxSelectorCompany.FormattingEnabled = true;
+ comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
+ comboBoxSelectorCompany.Location = new Point(6, 428);
+ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
+ comboBoxSelectorCompany.Size = new Size(314, 38);
+ comboBoxSelectorCompany.TabIndex = 0;
+ comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
+ //
+ // pictureBox
+ //
+ pictureBox.Dock = DockStyle.Fill;
+ pictureBox.Location = new Point(0, 0);
+ pictureBox.Name = "pictureBox";
+ pictureBox.Size = new Size(1176, 961);
+ pictureBox.TabIndex = 1;
+ pictureBox.TabStop = false;
+ //
+ // FormWarshipCollection
+ //
+ AutoScaleDimensions = new SizeF(12F, 30F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1502, 961);
+ Controls.Add(pictureBox);
+ Controls.Add(groupBoxTools);
+ Name = "FormWarshipCollection";
+ Text = "Коллекция военных кораблей";
+ groupBoxTools.ResumeLayout(false);
+ panelCompanyTools.ResumeLayout(false);
+ panelCompanyTools.PerformLayout();
+ panelStorage.ResumeLayout(false);
+ panelStorage.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonAddWarship;
+ private ComboBox comboBoxSelectorCompany;
+ private Button buttonAddAircraftCarrier;
+ private PictureBox pictureBox;
+ private Button buttonRefresh;
+ private Button buttonGoToCheck;
+ private Button buttonRemoveWarship;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Panel panelStorage;
+ private RadioButton radioButtonList;
+ private RadioButton radioButtonMassive;
+ private TextBox textBoxCollectionName;
+ private Label labelCollectionName;
+ private Button buttonCollectionDel;
+ private ListBox listBoxCollection;
+ private Button buttonCollectionAdd;
+ private Button buttonCreateCompany;
+ private Panel panelCompanyTools;
+ }
+}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs
new file mode 100644
index 0000000..7d45fa5
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs
@@ -0,0 +1,281 @@
+using ProjectAircraftCarrier_.CollectionGenericObjects;
+using ProjectAircraftCarrier_.Drawnings;
+
+namespace ProjectAircraftCarrier_;
+
+///
+/// Форма работы с компанией и ее коллекцией
+///
+public partial class FormWarshipCollection : Form
+{
+ ///
+ /// Хранилище коллекций
+ ///
+ private readonly StorageCollection _storageCollection;
+
+ ///
+ /// Компания
+ ///
+ private AbstractCompany? _company = null;
+
+ ///
+ /// Конструктор
+ ///
+ public FormWarshipCollection()
+ {
+ InitializeComponent();
+ _storageCollection = new();
+ }
+
+ ///
+ /// Выбор компании
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ panelCompanyTools.Enabled = false;
+ }
+
+ ///
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ Random random = new();
+ DrawningWarship drawningWarship;
+ switch (type)
+ {
+ case nameof(DrawningWarship):
+ drawningWarship = new DrawningWarship(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
+ break;
+ case nameof(DrawningAircraftCarrier):
+ drawningWarship = new DrawningAircraftCarrier(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+
+ if (_company + drawningWarship != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+
+ ///
+ /// Получение цвета
+ ///
+ /// Генератор случайных чисел
+ ///
+ private static Color GetColor(Random random)
+ {
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+
+ return color;
+ }
+
+ ///
+ /// Добавление военного корабля
+ ///
+ ///
+ ///
+ private void ButtonAddWarship_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarship));
+
+ ///
+ /// Добавление авианосца
+ ///
+ ///
+ ///
+ private void ButtonAddAircraftCarrier_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAircraftCarrier));
+
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveWarship_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
+ {
+ return;
+ }
+
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+
+ int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+ if (_company - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _company.Show();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ ///
+ /// Передача объекта в другую форму
+ ///
+ ///
+ ///
+ private void ButtonGoToCheck_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ DrawningWarship? warship = null;
+ int counter = 100;
+ while (warship == null)
+ {
+ warship = _company.GetRandomObject();
+ counter--;
+ if (counter <= 0)
+ {
+ break;
+ }
+ }
+
+ if (warship == null)
+ {
+ return;
+ }
+
+ FormAircraftCarrier form = new()
+ {
+ SetWarship = warship
+ };
+ form.ShowDialog();
+ }
+
+ ///
+ /// Перерисовка коллекции
+ ///
+ ///
+ ///
+ private void ButtonRefresh_Click(object sender, EventArgs e)
+ {
+ if (_company == null)
+ {
+ return;
+ }
+
+ pictureBox.Image = _company.Show();
+ }
+
+ ///
+ /// Добавление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionAdd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
+ {
+ MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ CollectionType collectionType = CollectionType.None;
+ if (radioButtonMassive.Checked)
+ {
+ collectionType = CollectionType.Massive;
+ }
+ else if (radioButtonList.Checked)
+ {
+ collectionType = CollectionType.List;
+ }
+
+ _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
+ RerfreshListBoxItems();
+ }
+
+ ///
+ /// Удаление коллекции
+ ///
+ ///
+ ///
+ private void ButtonCollectionDel_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ if (MessageBox.Show("Вы уверены, что хотите удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+ {
+ return;
+ }
+ _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
+ RerfreshListBoxItems();
+ }
+
+ ///
+ /// Обновление списка в listBoxCollection
+ ///
+ private void RerfreshListBoxItems()
+ {
+ listBoxCollection.Items.Clear();
+ for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
+ {
+ string? colName = _storageCollection.Keys?[i];
+ if (!string.IsNullOrEmpty(colName))
+ {
+ listBoxCollection.Items.Add(colName);
+ }
+ }
+ }
+
+ ///
+ /// Создание компании
+ ///
+ ///
+ ///
+ private void ButtonCreateCompany_Click(object sender, EventArgs e)
+ {
+ if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
+ {
+ MessageBox.Show("Коллекция не выбрана");
+ return;
+ }
+
+ ICollectionGenericObjects? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
+ if (collection == null)
+ {
+ MessageBox.Show("Коллекция не проинициализирована");
+ return;
+ }
+
+ switch (comboBoxSelectorCompany.Text)
+ {
+ case "Хранилище":
+ _company = new Docks(pictureBox.Width, pictureBox.Height, collection);
+ break;
+ }
+ panelCompanyTools.Enabled = true;
+ RerfreshListBoxItems();
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.resx b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.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/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/AbstractStrategy.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/AbstractStrategy.cs
new file mode 100644
index 0000000..fb95395
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/AbstractStrategy.cs
@@ -0,0 +1,135 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Класс-стратегия перемещения объекта
+///
+public abstract class AbstractStrategy
+{
+ ///
+ /// Перемещаемый объект
+ ///
+ private IMoveableObject? _moveableObject;
+
+ ///
+ /// Статус перемещения
+ ///
+ private StrategyStatus _state = StrategyStatus.NotInit;
+
+ ///
+ /// Ширина поля
+ ///
+ protected int FieldWidth { get; private set; }
+
+ ///
+ /// Высота поля
+ ///
+ protected int FieldHeight { get; private set; }
+
+ ///
+ /// Статус перемещения
+ ///
+ public StrategyStatus GetStatus() { return _state; }
+
+ ///
+ /// Установка данных
+ ///
+ /// Перемещаемый объект
+ /// Ширина поля
+ /// Высота поля
+ public void SetData(IMoveableObject moveableObject, int width, int height)
+ {
+ if (moveableObject == null)
+ {
+ _state = StrategyStatus.NotInit;
+ return;
+ }
+ _state = StrategyStatus.InProgress;
+ _moveableObject = moveableObject;
+ FieldWidth = width;
+ FieldHeight = height;
+ }
+
+ ///
+ /// Шаг перемещения
+ ///
+ public void MakeStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return;
+ }
+ if (IsTargetDestinaion())
+ {
+ _state = StrategyStatus.Finish;
+ return;
+ }
+ MoveToTarget();
+ }
+
+ ///
+ /// Перемещение влево
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveLeft() => MoveTo(MovementDirection.Left);
+
+ ///
+ /// Перемещение вправо
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveRight() => MoveTo(MovementDirection.Right);
+
+ ///
+ /// Перемещение вверх
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveUp() => MoveTo(MovementDirection.Up);
+
+ ///
+ /// Перемещение вниз
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveDown() => MoveTo(MovementDirection.Down);
+
+ ///
+ /// Параметры объекта
+ ///
+ protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
+
+ ///
+ /// Шаг объекта
+ ///
+ ///
+ protected int? GetStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return null;
+ }
+ return _moveableObject?.GetStep;
+ }
+
+ ///
+ /// Перемещение к цели
+ ///
+ protected abstract void MoveToTarget();
+
+ ///
+ /// Достигнута ли цель
+ ///
+ ///
+ protected abstract bool IsTargetDestinaion();
+
+ ///
+ /// Попытка перемещения в требуемом направлении
+ ///
+ /// Направление
+ /// Результат попытки (true - удалось переместиться, false - неудача)
+ private bool MoveTo(MovementDirection movementDirection)
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return false;
+ }
+ return _moveableObject?.TryMoveObject(movementDirection) ?? false;
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/IMoveableObject.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/IMoveableObject.cs
new file mode 100644
index 0000000..f4abc81
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/IMoveableObject.cs
@@ -0,0 +1,24 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Интерфейс для работы с перемещаемым объектом
+///
+public interface IMoveableObject
+{
+ ///
+ /// Получение координаты объекта
+ ///
+ ObjectParameters? GetObjectPosition { get; }
+
+ ///
+ /// Шаг объекта
+ ///
+ int GetStep { get; }
+
+ ///
+ /// Попытка переместить объект в указанном направлении
+ ///
+ /// Направление
+ /// true - объект перемещен, false - перемещение невозможно
+ bool TryMoveObject(MovementDirection direction);
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToBorder.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToBorder.cs
new file mode 100644
index 0000000..74c4a6a
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToBorder.cs
@@ -0,0 +1,55 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Стратегия перемещения объекта к краю
+///
+public class MoveToBorder : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ return objParams.RightBoarder - GetStep() <= FieldWidth
+ && objParams.RightBoarder + GetStep() >= FieldWidth &&
+ objParams.DownBoarder - GetStep() <= FieldHeight
+ && objParams.DownBoarder + GetStep() >= FieldHeight;
+ }
+
+ protected override void MoveToTarget()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return;
+ }
+
+ int diffX = objParams.RightBoarder - FieldWidth;
+ if (Math.Abs(diffX) > GetStep())
+ {
+ if (diffX > 0)
+ {
+ MoveLeft();
+ }
+ else
+ {
+ MoveRight();
+ }
+ }
+
+ int diffY = objParams.DownBoarder - FieldHeight;
+ if (Math.Abs(diffY) > GetStep())
+ {
+ if (diffY > 0)
+ {
+ MoveUp();
+ }
+ else
+ {
+ MoveDown();
+ }
+ }
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToCenter.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToCenter.cs
new file mode 100644
index 0000000..9e00036
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveToCenter.cs
@@ -0,0 +1,53 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Стратегия перемещения объекта в центр экрана
+///
+public class MoveToCenter : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2
+ && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
+ objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2
+ && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
+ }
+
+ protected override void MoveToTarget()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return;
+ }
+ int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
+ if (Math.Abs(diffX) > GetStep())
+ {
+ if (diffX > 0)
+ {
+ MoveLeft();
+ }
+ else
+ {
+ MoveRight();
+ }
+ }
+ int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
+ if (Math.Abs(diffY) > GetStep())
+ {
+ if (diffY > 0)
+ {
+ MoveUp();
+ }
+ else
+ {
+ MoveDown();
+ }
+ }
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveableWarship.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveableWarship.cs
new file mode 100644
index 0000000..079790f
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MoveableWarship.cs
@@ -0,0 +1,61 @@
+using ProjectAircraftCarrier_.Drawnings;
+
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Класс-реализация IMoveableObject с использованием DrawningWarship
+///
+public class MoveableWarship : IMoveableObject
+{
+ private readonly DrawningWarship? _warship = null;
+
+ ///
+ /// Конструктор
+ ///
+ /// Объект класса DrawningWarship
+ public MoveableWarship(DrawningWarship warship)
+ {
+ _warship = warship;
+ }
+
+ public ObjectParameters? GetObjectPosition
+ {
+ get
+ {
+ if (_warship == null || _warship.EntityWarship == null || !_warship.GetPosX.HasValue || !_warship.GetPosY.HasValue)
+ {
+ return null;
+ }
+ return new ObjectParameters(_warship.GetPosX.Value, _warship.GetPosY.Value, _warship.GetWidth, _warship.GetHeight);
+ }
+ }
+
+ public int GetStep => (int)(_warship?.EntityWarship?.Step ?? 0);
+
+ public bool TryMoveObject(MovementDirection direction)
+ {
+ if (_warship == null || _warship.EntityWarship == null)
+ {
+ return false;
+ }
+ return _warship.MoveTransport(GetDirectionType(direction));
+ }
+
+ ///
+ /// Конвертация из MovementDirection в DirectionType
+ ///
+ /// MovementDirection
+ /// DirectionType
+ private static DirectionType GetDirectionType(MovementDirection direction)
+ {
+ return direction switch
+ {
+ MovementDirection.Left => DirectionType.Left,
+ MovementDirection.Right => DirectionType.Right,
+ MovementDirection.Up => DirectionType.Up,
+ MovementDirection.Down => DirectionType.Down,
+ _ => DirectionType.Unknow,
+ };
+ }
+
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MovementDirection.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MovementDirection.cs
new file mode 100644
index 0000000..cefd0b0
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/MovementDirection.cs
@@ -0,0 +1,28 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Направление перемещения
+///
+public enum MovementDirection
+{
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+
+ ///
+ /// Влево
+ ///
+ Left = 3,
+
+ ///
+ /// Вправо
+ ///
+ Right = 4
+
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/ObjectParameters.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/ObjectParameters.cs
new file mode 100644
index 0000000..02e0fb2
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/ObjectParameters.cs
@@ -0,0 +1,72 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Параметры координаты объекта
+///
+public class ObjectParameters
+{
+ ///
+ /// Координата X
+ ///
+ private readonly int _x;
+
+ ///
+ /// Координата Y
+ ///
+ private readonly int _y;
+
+ ///
+ /// Ширина объекта
+ ///
+ private readonly int _width;
+
+ ///
+ /// Высота объекта
+ ///
+ private readonly int _height;
+
+ ///
+ /// Левая граница
+ ///
+ public int LeftBoarder => _x;
+
+ ///
+ /// Верхняя граница
+ ///
+ public int TopBoarder => _y;
+
+ ///
+ /// Правая граница
+ ///
+ public int RightBoarder => _x + _width;
+
+ ///
+ /// Нижняя граница
+ ///
+ public int DownBoarder => _y + _height;
+
+ ///
+ /// Середина объекта
+ ///
+ public int ObjectMiddleHorizontal => _x + _width / 2;
+
+ ///
+ /// Середина объекта
+ ///
+ public int ObjectMiddleVertical => _y + _height / 2;
+
+ ///
+ /// Конструктор
+ ///
+ /// Координата X
+ /// Координата Y
+ /// Ширина объекта
+ /// Высота объекта
+ public ObjectParameters(int x, int y, int width, int height)
+ {
+ _x = x;
+ _y = y;
+ _width = width;
+ _height = height;
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/StrategyStatus.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/StrategyStatus.cs
new file mode 100644
index 0000000..13cccf8
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/MovementStrategy/StrategyStatus.cs
@@ -0,0 +1,22 @@
+namespace ProjectAircraftCarrier_.MovementStrategy;
+
+///
+/// Статус выполнения операции перемещения
+///
+public enum StrategyStatus
+{
+ ///
+ /// Всё готово к началу
+ ///
+ NotInit,
+
+ ///
+ /// Выполняется
+ ///
+ InProgress,
+
+ ///
+ /// Завершено
+ ///
+ Finish
+}
diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/Program.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Program.cs
similarity index 82%
rename from ProjectAircraftCarrier/ProjectAircraftCarrier/Program.cs
rename to ProjectAircraftCarrier_/ProjectAircraftCarrier_/Program.cs
index 1ba11b2..332bbfa 100644
--- a/ProjectAircraftCarrier/ProjectAircraftCarrier/Program.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Program.cs
@@ -1,4 +1,4 @@
-namespace ProjectAircraftCarrier
+namespace ProjectAircraftCarrier_
{
internal static class Program
{
@@ -11,7 +11,7 @@ namespace ProjectAircraftCarrier
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new FormWarshipCollection());
}
}
}
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/ProjectAircraftCarrier_.csproj b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/ProjectAircraftCarrier_.csproj
new file mode 100644
index 0000000..af03d74
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/ProjectAircraftCarrier_.csproj
@@ -0,0 +1,26 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.Designer.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..7d74f48
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.Designer.cs
@@ -0,0 +1,103 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программой.
+// Исполняемая версия:4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
+// повторной генерации кода.
+//
+//------------------------------------------------------------------------------
+
+namespace ProjectAircraftCarrier_.Properties {
+ using System;
+
+
+ ///
+ /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
+ ///
+ // Этот класс создан автоматически классом StronglyTypedResourceBuilder
+ // с помощью такого средства, как ResGen или Visual Studio.
+ // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
+ // с параметром /str или перестройте свой проект VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectAircraftCarrier_.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Перезаписывает свойство CurrentUICulture текущего потока для всех
+ /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowDown {
+ get {
+ object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowLeft {
+ get {
+ object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowRight {
+ get {
+ object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap arrowUp {
+ get {
+ object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.resx b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.resx
new file mode 100644
index 0000000..dc6b4c5
--- /dev/null
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Properties/Resources.resx
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+
+ ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowDown.png b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowDown.png
new file mode 100644
index 0000000..08436f4
Binary files /dev/null and b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowDown.png differ
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowLeft.png b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowLeft.png
new file mode 100644
index 0000000..c8a7f4c
Binary files /dev/null and b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowLeft.png differ
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowRight.png b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowRight.png
new file mode 100644
index 0000000..bd0fe69
Binary files /dev/null and b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowRight.png differ
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowUp.png b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowUp.png
new file mode 100644
index 0000000..ac183c5
Binary files /dev/null and b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/Resources/arrowUp.png differ