diff --git a/ProjectBulldozer/ProjectBulldozer/DirectionType.cs b/ProjectBulldozer/ProjectBulldozer/DirectionType.cs
index 4628515..bbebbd0 100644
--- a/ProjectBulldozer/ProjectBulldozer/DirectionType.cs
+++ b/ProjectBulldozer/ProjectBulldozer/DirectionType.cs
@@ -1,29 +1,31 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace ProjectBulldozer.Drawnings;
-namespace ProjectBulldozer;
+///
+/// Направление перемещения
+///
public enum DirectionType
{
- ///
- /// Вверх
- ///
- Up = 1,
- ///
- /// Вниз
- ///
- Down = 2,
- ///
- /// Влево
- ///
- Left = 3,
- ///
- /// Вправо
- ///
- Right = 4
-
+///
+/// Неизвестное направление
+///
+Unknow = -1,
+///
+/// Вверх
+///
+Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
}
+
//сделано
\ No newline at end of file
diff --git a/ProjectBulldozer/ProjectBulldozer/DrawingBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/DrawingBulldozer.cs
deleted file mode 100644
index 9f51410..0000000
--- a/ProjectBulldozer/ProjectBulldozer/DrawingBulldozer.cs
+++ /dev/null
@@ -1,278 +0,0 @@
-namespace ProjectBulldozer;
-
-///
-/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
-///
-public class DrawningBulldozer
-{
- ///
- /// Класс-сущность
- ///
- public EntityBulldozer? EntityBulldozer { get; private set; }
- ///
- /// Ширина окна
- ///
- private int? _pictureWidth;
- ///
- /// Высота окна
- ///
- private int? _pictureHeight;
- ///
- /// Левая координата прорисовки автомобиля
- ///
- private int? _startPosX;
- ///
- /// Верхняя кооридната прорисовки автомобиля
- ///
- private int? _startPosY;
-
- ///
- /// Ширина прорисовки автомобиля
- ///
- private readonly int _BulldozerWidth = 180;
- ///
- /// Высота прорисовки автомобиля
- ///
- private readonly int _BulldozerHeight = 140;
- ///
- /// Инициализация свойств
- ///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия отвала спереди
- /// Признак наличия рыхлителя сзади
-
- public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool additionalOtval, bool additionalRihl)
- {
- EntityBulldozer = new EntityBulldozer();
- EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, additionalOtval,
- additionalRihl);
-
- _pictureWidth = null;
- _pictureHeight = null;
- _startPosX = null;
- _startPosY = null;
-
- }
- ///
- /// Установка границ поля
- ///
- /// Ширина поля
- /// Высота поля
- /// true - границы заданы, false - проверка не пройдена, нельзя
- public bool SetPictureSize(int width, int height)
- {
- if (_BulldozerWidth < width && _BulldozerHeight < height)
- {
- _pictureWidth = width;
- _pictureHeight = height;
- if (_startPosX.HasValue && _startPosY.HasValue)
- {
- SetPosition(_startPosX.Value, _startPosY.Value);
- }
-
- return true;
- }
- return false;
- }
- ///
- /// Установка позиции
- ///
- /// Координата X
- /// Координата Y
- public void SetPosition(int x, int y)
- {
- if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
- {
- return;
- }
- if (x < 0 || x + _BulldozerWidth > _pictureWidth || y < 0 || y + _BulldozerHeight > _pictureHeight)
- {
- _startPosX = _pictureWidth - _BulldozerWidth;
- _startPosY = _pictureHeight - _BulldozerHeight;
- }
- else
- {
- _startPosX = x;
- _startPosY = y;
- }
- }
- ///
- /// Изменение направления перемещения
- ///
- /// Направление
- /// true - перемещене выполнено, false - перемещение
- public bool MoveTransport(DirectionType direction) {
-
- if (EntityBulldozer == null || !_startPosX.HasValue ||
- !_startPosY.HasValue)
- {
- return false;
- }
- switch (direction)
- {
- //влево
- case DirectionType.Left:
- if (_startPosX.Value - EntityBulldozer.Step > 0)
- {
- _startPosX -= (int)EntityBulldozer.Step;
- }
- return true;
-
- //вверх
- case DirectionType.Up:
- if (_startPosY.Value - EntityBulldozer.Step > 0)
- {
- _startPosY -= (int)EntityBulldozer.Step;
- }
- return true;
-
- // вправо
- case DirectionType.Right:
- if (_startPosX + _BulldozerWidth + EntityBulldozer.Step < _pictureWidth)
- {
- _startPosX += (int)EntityBulldozer.Step;
- }
- return true;
-
- //вниз
- case DirectionType.Down:
- if (_startPosY + _BulldozerHeight + EntityBulldozer.Step < _pictureHeight)
- {
- _startPosY += (int)EntityBulldozer.Step;
- }
- return true;
- default:
- return false;
- }
- }
-
- ///
- /// Прорисовка объекта
- ///
- ///
- public void DrawTransport(Graphics g)
- {
- if (EntityBulldozer == null || !_startPosX.HasValue ||
- !_startPosY.HasValue)
- {
- return;
- }
- Pen pen = new(Color.Black);
- Brush brush = new SolidBrush(Color.Black);
- Brush bl = new SolidBrush(EntityBulldozer.AdditionalColor);
- Brush bodyBrush = new SolidBrush(EntityBulldozer.BodyColor);
- Brush bodyBrush2 = new SolidBrush(EntityBulldozer.AdditionalColor);
-
-
-
-
- //основное тело
- g.FillRectangle(bodyBrush, _startPosX.Value + 20, _startPosY.Value + 40, 120, 60);
-
- g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 40, 120, 60);
-
-
-
- //Гусеницы
- Brush gg = new SolidBrush(Color.LightGray);
- g.FillEllipse(gg, _startPosX.Value + 23, _startPosY.Value + 101, 118, 35);
- g.DrawEllipse(pen, _startPosX.Value + 23, _startPosY.Value + 101, 118, 35);
-
-
-
-
- g.DrawEllipse(pen, _startPosX.Value + 26, _startPosY.Value + 103, 110, 30);
-
- //катки в гусеницах
- Brush gr = new SolidBrush(Color.Gray);
- g.FillEllipse(gr, _startPosX.Value + 40, _startPosY.Value + 108, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 40, _startPosY.Value + 108, 20, 20);
-
-
- g.FillEllipse(gr, _startPosX.Value + 65, _startPosY.Value + 110, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 110, 20, 20);
-
- g.FillEllipse(gr, _startPosX.Value + 115, _startPosY.Value + 110, 15, 15);
- g.DrawEllipse(pen, _startPosX.Value + 115, _startPosY.Value + 110, 15, 15);
-
- g.FillEllipse(gr, _startPosX.Value + 90, _startPosY.Value + 110, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 110, 20, 20);
-
-
-
-
- //кабина водителя
- g.FillRectangle(bodyBrush2, _startPosX.Value + 20, _startPosY.Value, 40, 40);
- g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value, 40, 40);
-
-
- //выхлопная труба
- Brush brBr = new SolidBrush(Color.Brown);
-
- g.FillRectangle(brBr, _startPosX.Value + 110, _startPosY.Value, 15, 40);
- g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value, 15, 40);
-
-
-
- //Brush bl = new SolidBrush(Color.LightYellow);
- /////////отвал
- ///
- if (EntityBulldozer.AdditionalOtval)
- {
- Point[] Otval =
- {
- new Point(_startPosX.Value + 142, _startPosY.Value + 70),
- new Point(_startPosX.Value + 172, _startPosY.Value + 130),
- new Point(_startPosX.Value+ 142, _startPosY.Value + 130),
-
-
- };
-
- g.FillPolygon(bl, Otval);
- g.DrawPolygon(pen, Otval);
- }
-
-
-
-
-
- ///рыхлитель
- if (EntityBulldozer.AdditionalRihl)
- {
- Brush black = new SolidBrush(Color.Black);
- Point[] Rihl =
- {
- new Point(_startPosX.Value + 18 , _startPosY.Value + 60),
- new Point(_startPosX.Value + 18, _startPosY.Value + 80),
- new Point(_startPosX.Value, _startPosY.Value + 120),
-
- };
-
- g.FillPolygon(black, Rihl);
- g.DrawPolygon(pen, Rihl);
-
- Point[] Ttt =
- {
- new Point(_startPosX.Value + 18 , _startPosY.Value + 80),
- new Point(_startPosX.Value + 18, _startPosY.Value + 120),
- new Point(_startPosX.Value, _startPosY.Value + 50),
-
- };
- g.FillPolygon(black, Ttt);
- g.DrawPolygon(pen, Ttt);
-
- }
-
-
-
-
-
- }
-}
-
-
-
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs
new file mode 100644
index 0000000..4e1d045
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs
@@ -0,0 +1,31 @@
+namespace ProjectBulldozer.Drawnings;
+
+///
+/// Направление перемещения
+///
+public enum DirectionType1
+{
+ ///
+ /// Неизвестное направление
+ ///
+ Unknow = -1,
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+ ///
+ /// Влево
+ ///
+ Left = 3,
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
+
+
+//сделано
\ No newline at end of file
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawingBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawingBulldozer.cs
new file mode 100644
index 0000000..05f54f3
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawingBulldozer.cs
@@ -0,0 +1,104 @@
+using ProjectBulldozer.Entities;
+using System.Drawing;
+
+namespace ProjectBulldozer.Drawnings;
+
+///
+/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningBulldozer : DrawningBulldozerProstoy
+{
+
+ ///
+ /// конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия отвала спереди
+ /// Признак наличия рыхлителя сзади
+
+ public DrawningBulldozer(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool additionalOtval, bool additionalRihl, bool v) : base(180, 140)
+ {
+ EntityBulldozerProstoy = new EntityBulldozer(speed, weight, bodyColor, additionalColor, additionalOtval,
+ additionalRihl);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntityBulldozerProstoy == null || EntityBulldozerProstoy is not EntityBulldozer Bulldozer || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush bodyBrush = new SolidBrush(Bulldozer.BodyColor);
+ Brush bodyBrush2 = new SolidBrush(Bulldozer.AdditionalColor);
+
+
+
+
+ _startPosX += 10;
+ _startPosY += 5;
+
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+
+ Brush bl = new SolidBrush(Bulldozer.AdditionalColor);
+ /////////отвал
+ ///
+ if (Bulldozer.AdditionalOtval)
+ {
+ Point[] Otval =
+ {
+ new Point(_startPosX.Value + 142, _startPosY.Value + 70),
+ new Point(_startPosX.Value + 172, _startPosY.Value + 130),
+ new Point(_startPosX.Value+ 142, _startPosY.Value + 130),
+
+
+ };
+
+ g.FillPolygon(bl, Otval);
+ g.DrawPolygon(pen, Otval);
+ }
+
+
+
+
+
+ ///рыхлитель
+ if (Bulldozer.AdditionalRihl)
+ {
+ Brush black = new SolidBrush(Color.Black);
+ Point[] Rihl =
+ {
+ new Point(_startPosX.Value + 18 , _startPosY.Value + 60),
+ new Point(_startPosX.Value + 18, _startPosY.Value + 80),
+ new Point(_startPosX.Value, _startPosY.Value + 120),
+
+ };
+
+ g.FillPolygon(black, Rihl);
+ g.DrawPolygon(pen, Rihl);
+
+ Point[] Ttt =
+ {
+ new Point(_startPosX.Value + 18 , _startPosY.Value + 80),
+ new Point(_startPosX.Value + 18, _startPosY.Value + 120),
+ new Point(_startPosX.Value, _startPosY.Value + 50),
+
+ };
+ g.FillPolygon(black, Ttt);
+ g.DrawPolygon(pen, Ttt);
+
+ }
+ }
+}
+
+
+
+
+
+
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozerProstoy.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozerProstoy.cs
new file mode 100644
index 0000000..b0cb10b
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozerProstoy.cs
@@ -0,0 +1,252 @@
+using ProjectBulldozer.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBulldozer.Drawnings;
+
+public class DrawningBulldozerProstoy
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityBulldozerProstoy? EntityBulldozerProstoy { get; protected set; }
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ protected int? _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ protected int? _startPosY;
+
+ ///
+ /// Ширина прорисовки бульдозера
+ ///
+ private readonly int _BulldozerWidth = 130;
+ ///
+ /// Высота прорисовки бульдозера
+ ///
+ private readonly int _BulldozerHeight = 120;
+
+ ///
+ /// Координата X объекта
+ ///
+ public int? GetPosX => _startPosX;
+ ///
+ /// Координата Y объекта
+ ///
+ public int? GetPosY => _startPosY;
+ ///
+ /// Ширина объекта
+ ///
+ public int GetWidth => _BulldozerWidth;
+ ///
+ /// Высота объекта
+ ///
+ public int GetHeight => _BulldozerHeight;
+
+
+ ///
+ /// Пустой конструктор
+ ///
+ private DrawningBulldozerProstoy()
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningBulldozerProstoy(int speed, double weight, Color bodyColor) : this()
+ {
+ EntityBulldozerProstoy = new EntityBulldozerProstoy(speed, weight, bodyColor);
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+
+ }
+
+ ///
+ /// Конструктор для наследников
+ ///
+ /// Ширина прорисовки бульдозера
+ /// Высота прорисовки бульдозера
+ protected DrawningBulldozerProstoy(int BulldozerWidth, int BulldozerHeight) : this()
+ {
+ _BulldozerWidth = BulldozerWidth;
+ _BulldozerHeight = BulldozerHeight;
+
+
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя
+ public bool SetPictureSize(int width, int height)
+ {
+ if (_BulldozerWidth < width && _BulldozerHeight < height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_startPosX.HasValue && _startPosY.HasValue)
+ {
+ SetPosition(_startPosX.Value, _startPosY.Value);
+ }
+
+ return true;
+ }
+ return false;
+ }
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+ if (x < 0 || x + _BulldozerWidth > _pictureWidth || y < 0 || y + _BulldozerHeight > _pictureHeight)
+ {
+ _startPosX = _pictureWidth - _BulldozerWidth;
+ _startPosY = _pictureHeight - _BulldozerHeight;
+ }
+ else
+ {
+ _startPosX = x;
+ _startPosY = y;
+ }
+ }
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение
+ public bool MoveTransport(DirectionType direction)
+ {
+
+ if (EntityBulldozerProstoy == null || !_startPosX.HasValue ||
+ !_startPosY.HasValue)
+ {
+ return false;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityBulldozerProstoy.Step > 0)
+ {
+ _startPosX -= (int)EntityBulldozerProstoy.Step;
+ }
+ return true;
+
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityBulldozerProstoy.Step > 0)
+ {
+ _startPosY -= (int)EntityBulldozerProstoy.Step;
+ }
+ return true;
+
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX + _BulldozerWidth + EntityBulldozerProstoy.Step < _pictureWidth)
+ {
+ _startPosX += (int)EntityBulldozerProstoy.Step;
+ }
+ return true;
+
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY + _BulldozerHeight + EntityBulldozerProstoy.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityBulldozerProstoy.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public virtual void DrawTransport(Graphics g)
+ {
+ if (EntityBulldozerProstoy == null || !_startPosX.HasValue ||
+ !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush brush = new SolidBrush(Color.Black);
+ Brush bodyBrush = new SolidBrush(EntityBulldozerProstoy.BodyColor);
+
+
+ //основное тело
+ g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 35, 120, 60);
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 35, 120, 60);
+
+
+
+ //Гусеницы
+ Brush gg = new SolidBrush(Color.LightGray);
+ g.FillEllipse(gg, _startPosX.Value + 13, _startPosY.Value + 96, 118, 35);
+ g.DrawEllipse(pen, _startPosX.Value + 13, _startPosY.Value + 96, 118, 35);
+
+ g.DrawEllipse(pen, _startPosX.Value + 16, _startPosY.Value + 98, 110, 30);
+
+ //катки в гусеницах
+ Brush gr = new SolidBrush(Color.Gray);
+ g.FillEllipse(gr, _startPosX.Value + 30, _startPosY.Value + 104, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 104, 20, 20);////
+
+
+ g.FillEllipse(gr, _startPosX.Value + 55, _startPosY.Value + 105, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 105, 20, 20);
+
+ g.FillEllipse(gr, _startPosX.Value + 105, _startPosY.Value + 105, 15, 15);
+ g.DrawEllipse(pen, _startPosX.Value + 105, _startPosY.Value + 105, 15, 15);
+
+ g.FillEllipse(gr, _startPosX.Value + 80, _startPosY.Value + 105, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 105, 20, 20);
+
+ //кабина водителя
+ g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value, 40, 40);
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value, 40, 40);
+
+
+ //выхлопная труба
+ Brush brBr = new SolidBrush(Color.Brown);
+
+ g.FillRectangle(brBr, _startPosX.Value + 100, _startPosY.Value, 15, 40);
+ g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value, 15, 40);
+
+
+ }
+}
diff --git a/ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
similarity index 63%
rename from ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs
rename to ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
index 49856e7..c2be6f2 100644
--- a/ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
@@ -1,20 +1,11 @@
-
-namespace ProjectBulldozer;
+namespace ProjectBulldozer.Entities;
-public class EntityBulldozer
+public class EntityBulldozer : EntityBulldozerProstoy
{
- ///
- /// Скорость
- ///
- public int Speed { get; private set; }
- ///
- /// Вес
- ///
- public double Weight { get; private set; }
- ///
- /// Основной цвет
- ///
- public Color BodyColor { get; private set; }
+ public EntityBulldozer(int speed, double weight, Color bodyColor) : base(speed, weight, bodyColor)
+ {
+ }
+
///
/// Дополнительный цвет (для опциональных элементов)
///
@@ -28,10 +19,8 @@ public class EntityBulldozer
///
public bool AdditionalRihl { get; private set; }
- ///
- /// Шаг перемещения автомобиля
- ///
- public double Step => Speed * 100 / Weight;
+
+
///
/// Инициализация полей объекта-класса спортивного автомобиля
///
@@ -41,12 +30,9 @@ public class EntityBulldozer
/// Дополнительный цвет
/// Признак наличия отвала спереди
/// Признак наличия рыхлителя сзади
- public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool additionalOtval, bool additionalRihl)
+ public EntityBulldozer(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool additionalOtval, bool additionalRihl) : base(speed, weight, bodyColor)
{
- Speed = speed;
- Weight = weight;
- BodyColor = bodyColor;
AdditionalColor = additionalColor;
AdditionalOtval = additionalOtval;
AdditionalRihl = additionalRihl;
diff --git a/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozerProstoy.cs b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozerProstoy.cs
new file mode 100644
index 0000000..ec67c8b
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozerProstoy.cs
@@ -0,0 +1,41 @@
+namespace ProjectBulldozer.Entities;
+
+///
+/// Класс-сущность "Бульдозер простой"
+///
+public class EntityBulldozerProstoy
+{
+ ///
+ /// Скорость
+ ///
+ 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 EntityBulldozerProstoy(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+
+
+ }
+}
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.Designer.cs b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.Designer.cs
index 5d8a28c..707f787 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.Designer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.Designer.cs
@@ -34,6 +34,9 @@
buttonDown = new Button();
buttonLeft = new Button();
buttonUp = new Button();
+ buttonCreateBulldozerProstoy = new Button();
+ ButtonStrategyStep = new Button();
+ comboBoxStrategy = new ComboBox();
((System.ComponentModel.ISupportInitialize)pictureBoxBulldozer).BeginInit();
SuspendLayout();
//
@@ -51,9 +54,9 @@
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 511);
buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(94, 29);
+ buttonCreate.Size = new Size(231, 29);
buttonCreate.TabIndex = 1;
- buttonCreate.Text = "Создать";
+ buttonCreate.Text = "Создать бульозер с доп.";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreateBulldozer_Click;
//
@@ -105,9 +108,43 @@
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
+ // buttonCreateBulldozerProstoy
+ //
+ buttonCreateBulldozerProstoy.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateBulldozerProstoy.Location = new Point(274, 511);
+ buttonCreateBulldozerProstoy.Name = "buttonCreateBulldozerProstoy";
+ buttonCreateBulldozerProstoy.Size = new Size(231, 29);
+ buttonCreateBulldozerProstoy.TabIndex = 6;
+ buttonCreateBulldozerProstoy.Text = "Создать простой бульдозер";
+ buttonCreateBulldozerProstoy.UseVisualStyleBackColor = true;
+ buttonCreateBulldozerProstoy.Click += buttonCreateBulldozerProstoy_Click;
+ //
+ // ButtonStrategyStep
+ //
+ ButtonStrategyStep.Location = new Point(793, 46);
+ ButtonStrategyStep.Name = "ButtonStrategyStep";
+ ButtonStrategyStep.Size = new Size(94, 29);
+ ButtonStrategyStep.TabIndex = 8;
+ ButtonStrategyStep.Text = "Шаг";
+ ButtonStrategyStep.UseVisualStyleBackColor = true;
+ ButtonStrategyStep.Click += ButtonStrategyStep_Click;
+ //
+ // comboBoxStrategy
+ //
+ comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxStrategy.FormattingEnabled = true;
+ comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
+ comboBoxStrategy.Location = new Point(744, 12);
+ comboBoxStrategy.Name = "comboBoxStrategy";
+ comboBoxStrategy.Size = new Size(143, 28);
+ comboBoxStrategy.TabIndex = 9;
+ //
// FormBulldozer
//
ClientSize = new Size(899, 552);
+ Controls.Add(comboBoxStrategy);
+ Controls.Add(ButtonStrategyStep);
+ Controls.Add(buttonCreateBulldozerProstoy);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
Controls.Add(buttonDown);
@@ -128,5 +165,8 @@
private Button buttonDown;
private Button buttonLeft;
private Button buttonUp;
+ private Button buttonCreateBulldozerProstoy;
+ private Button ButtonStrategyStep;
+ private ComboBox comboBoxStrategy;
}
}
\ No newline at end of file
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
index ffb86de..05430b4 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
@@ -1,4 +1,6 @@
-using System;
+using ProjectBulldozer.Drawnings;
+using ProjectBulldozer.MovementStrategy;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -15,47 +17,79 @@ namespace ProjectBulldozer
///
/// Поле-объект для прорисовки объекта
///
- private DrawningBulldozer? _drawningBulldozer;
+ private DrawningBulldozerProstoy? _drawningBulldozerProstoy;
+
+ private AbstractStrategy? _strategy;
///
/// Конструктор формы
///
public FormBulldozer()
{
InitializeComponent();
+ _strategy = null;
}
///
/// Метод прорисовки машины
///
private void Draw()
{
- if (_drawningBulldozer == null)
+ if (_drawningBulldozerProstoy == null)
{
return;
}
Bitmap bmp = new(pictureBoxBulldozer.Width,
pictureBoxBulldozer.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningBulldozer.DrawTransport(gr);
+ _drawningBulldozerProstoy.DrawTransport(gr);
pictureBoxBulldozer.Image = bmp;
}
+
///
- /// Обработка нажатия кнопки "Создать"
+ /// создеание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ Random random = new();
+ switch (type)
+ {
+ case nameof(DrawningBulldozerProstoy):
+ _drawningBulldozerProstoy = new DrawningBulldozerProstoy(random.Next(100, 300), random.Next(1000, 3000),
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
+ break;
+ case nameof(DrawningBulldozer):
+ _drawningBulldozerProstoy = new DrawningBulldozer(random.Next(100, 300), random.Next(1000, 3000),
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ Convert.ToBoolean(random.Next(0, 2)),
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+
+ _drawningBulldozerProstoy.SetPictureSize(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
+ _drawningBulldozerProstoy.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ _strategy = null;
+ comboBoxStrategy.Enabled = true;
+ Draw();
+ }
+
+
+ ///
+ /// Обработка нажатия кнопки "Создать бульдозер с доп."
///
///
///
- private void ButtonCreateBulldozer_Click(object sender, EventArgs e)
- {
- Random random = new();
- _drawningBulldozer = new DrawningBulldozer();
-
- _drawningBulldozer.Init(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- _drawningBulldozer.SetPictureSize(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
- _drawningBulldozer.SetPosition(random.Next(10, 100), random.Next(10, 100));
- Draw();
- }
+ private void ButtonCreateBulldozer_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBulldozer));
+
+ ///
+ /// Обработка нажатия кнопки "Создать обычный бульдозер"
+ ///
+ ///
+ ///
+ private void buttonCreateBulldozerProstoy_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBulldozerProstoy));
+
///
/// Перемещение объекта по форме (нажатие кнопок навигации)
///
@@ -63,7 +97,7 @@ namespace ProjectBulldozer
///
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningBulldozer == null)
+ if (_drawningBulldozerProstoy == null)
{
return;
}
@@ -73,19 +107,19 @@ namespace ProjectBulldozer
{
case "buttonUp":
result =
- _drawningBulldozer.MoveTransport(DirectionType1.Up);
+ _drawningBulldozerProstoy.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
result =
- _drawningBulldozer.MoveTransport(DirectionType1.Down);
+ _drawningBulldozerProstoy.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
result =
- _drawningBulldozer.MoveTransport(DirectionType1.Left);
+ _drawningBulldozerProstoy.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
result =
- _drawningBulldozer.MoveTransport(DirectionType1.Right);
+ _drawningBulldozerProstoy.MoveTransport(DirectionType.Right);
break;
}
if (result)
@@ -94,6 +128,48 @@ namespace ProjectBulldozer
}
}
+ private void ButtonStrategyStep_Click(object sender, EventArgs e)
+ {
+ if (_drawningBulldozerProstoy == null)
+ {
+ return;
+ }
+ if (comboBoxStrategy.Enabled)
+ {
+ _strategy = comboBoxStrategy.SelectedIndex switch
+ {
+ 0 => new MoveToCenter(),
+ 1 => new MoveToBorder(),
+ _ => null,
+ };
+ if (_strategy == null)
+ {
+ return;
+ }
+ _strategy.SetData(new MoveableBulldozer(_drawningBulldozerProstoy),
+ pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
+ }
+
+ if (_strategy == null)
+ {
+ return;
+ }
+
+ comboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
+ Draw();
+ if (_strategy.GetStatus() == StrategyStatus.Finish)
+ {
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ }
+
+ }
+
+ private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
+ {
+
+ }
}
}