diff --git a/ProjectBulldozer/ProjectBulldozer/DirectionType.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs
similarity index 91%
rename from ProjectBulldozer/ProjectBulldozer/DirectionType.cs
rename to ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs
index 26698c2..2fb2c1b 100644
--- a/ProjectBulldozer/ProjectBulldozer/DirectionType.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DirectionType.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace ProjectBulldozer;
+namespace ProjectBulldozer.Drawnings;
public enum DirectionType
{
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs
new file mode 100644
index 0000000..e8e388a
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectBulldozer.Entities;
+
+namespace ProjectBulldozer.Drawnings;
+
+///
+/// Класс отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningBulldozer : DrawningDozer
+{
+ ///
+ ///Конструктор
+ ///
+ /// ///Скорость
+ ///Вес
+ ///Основной цвет
+ ///Дополнительный цвет
+ ///Признак наличия отвала
+ ///Признак наличия гусеницы
+ public DrawningBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar) : base(150, 90)
+ {
+ EntityDozer = new EntityBulldozer(speed, weight, bodyColor, additionalColor, blade, caterpillar);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue || EntityDozer is not EntityBulldozer bulldozer)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
+ Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
+ //BULDOZER
+ //caterpillar
+ if (bulldozer.Caterpillar)
+ {
+ g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 150, 15);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 150, 15);
+ g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 75, 150, 15);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 75, 150, 15);
+ }
+
+ //blade
+ if (bulldozer.Blade)
+ { //smth like hands?
+ g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
+ g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
+ g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
+ g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
+ //blade itself
+ g.FillRectangle(bodyBrush, _startPosX.Value + 125, _startPosY.Value, 25, 90);
+ g.DrawRectangle(pen, _startPosX.Value + 125, _startPosY.Value, 25, 90);
+ g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value + 90);
+ }
+ _startPosX += 0;
+ _startPosY += 0;
+ base.DrawTransport(g);
+ _startPosX -= 0;
+ _startPosY -= 0;
+ }
+}
diff --git a/ProjectBulldozer/ProjectBulldozer/DrawningBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
similarity index 67%
rename from ProjectBulldozer/ProjectBulldozer/DrawningBulldozer.cs
rename to ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
index db79465..35a3f0b 100644
--- a/ProjectBulldozer/ProjectBulldozer/DrawningBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
@@ -1,20 +1,21 @@
-using System;
+using ProjectBulldozer.Entities;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace ProjectBulldozer;
+namespace ProjectBulldozer.Drawnings;
///
-/// Классб отвечающий за прорисовку и перемещение объекта-сущности
+/// Класс отвечающий за прорисовку и перемещение объекта-сущности
///
-internal class DrawningBulldozer
+public class DrawningDozer
{
///
/// Класс-сущность
///
- public EntityBulldozer? EntityBulldozer { get; private set; }
+ public EntityDozer? EntityDozer { get; protected set; }
///
///Ширина окна
@@ -29,12 +30,12 @@ internal class DrawningBulldozer
///
/// Левая координата прорисовки бульдозера
///
- private int? _startPosX;
+ protected int? _startPosX;
///
/// Верхнаяя координата прорисовки бульдозера
///
- private int? _startPosY;
+ protected int? _startPosY;
///
///Ширина прорисовки бульдозера
@@ -46,26 +47,42 @@ internal class DrawningBulldozer
///
private readonly int _drawningBulldozerHeight = 90;
- ///
- ///Инициализация свойств
+ ///
+ /// Пустой конструктор.
///
- /// ///Скорость
- ///Вес
- ///Основной цвет
- ///Дополнительный цвет
- ///Признак наличия отвала
- ///Признак наличия гусеницы
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar)
- //public void Init(EntityBulldozer entityBulldozer)
+ private DrawningDozer()
{
- EntityBulldozer = new EntityBulldozer();
- EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, blade, caterpillar);
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет(цвет колёс)
+ public DrawningDozer(int speed, double weight, Color bodyColor, Color additionalColor) : this()
+ {
+ EntityDozer = new EntityDozer(speed, weight, bodyColor, additionalColor);
+ }
+
+ ///
+ /// Конструктор для наследников
+ ///
+ /// Ширина прорисовки бульдозера
+ /// Высота прорисовки бульдозера
+ protected DrawningDozer (int drawningBulldozerWidth, int drawningBulldozerHeigh)
+ {
+ _drawningBulldozerWidth = drawningBulldozerWidth;
+ //????????
+ _pictureHeight = drawningBulldozerHeigh;
+ //????????
+ }
+
///
///Установка границ поля
///
@@ -104,7 +121,6 @@ internal class DrawningBulldozer
}
}
-
return true;
}
@@ -147,6 +163,7 @@ internal class DrawningBulldozer
_startPosY = y;
}
}
+
///
///Изменение направления перемещения
///
@@ -154,7 +171,7 @@ internal class DrawningBulldozer
/// true - перемещениие выполнено, false - перемещение невозможно
public bool MoveTransport(DirectionType direction)
{
- if (EntityBulldozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
@@ -163,51 +180,51 @@ internal class DrawningBulldozer
{
// влево
case DirectionType.Left:
- if (_startPosX.Value - EntityBulldozer.Step > 0)
+ if (_startPosX.Value - EntityDozer.Step > 0)
{
- _startPosX -= (int)EntityBulldozer.Step;
+ _startPosX -= (int)EntityDozer.Step;
}
return true;
// вверх
case DirectionType.Up:
- if (_startPosY.Value - EntityBulldozer.Step > 0)
+ if (_startPosY.Value - EntityDozer.Step > 0)
{
- _startPosY -= (int)EntityBulldozer.Step;
+ _startPosY -= (int)EntityDozer.Step;
}
return true;
// вправо
case DirectionType.Right:
- if (_startPosX.Value + EntityBulldozer.Step + _drawningBulldozerWidth < _pictureWidth)
+ if (_startPosX.Value + EntityDozer.Step + _drawningBulldozerWidth < _pictureWidth)
{
- _startPosX += (int)EntityBulldozer.Step;
+ _startPosX += (int)EntityDozer.Step;
}
return true;
// вниз
case DirectionType.Down:
- if (_startPosY.Value + EntityBulldozer.Step + _drawningBulldozerHeight < _pictureHeight)
+ if (_startPosY.Value + EntityDozer.Step + _drawningBulldozerHeight < _pictureHeight)
{
- _startPosY += (int)EntityBulldozer.Step;
+ _startPosY += (int)EntityDozer.Step;
}
return true;
+
default:
return false;
}
}
-
///
/// Прорисовка объекта
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
- if (EntityBulldozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
- Brush bodyBrush = new SolidBrush(EntityBulldozer.BodyColor);
- Brush additionalBrush = new SolidBrush(EntityBulldozer.AdditionalColor);
+ Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
+ Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
//BULDOZER
//body
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
@@ -234,27 +251,5 @@ internal class DrawningBulldozer
Brush windowBrush = new SolidBrush(Color.FromArgb(170, 170, 215));
g.FillRectangle(windowBrush, _startPosX.Value + 55, _startPosY.Value + 20, _drawningBulldozerWidth - 90, _drawningBulldozerHeight - 40);
g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 20, _drawningBulldozerWidth - 90, _drawningBulldozerHeight - 40);
-
- //caterpillar
- if (EntityBulldozer.Caterpillar)
- {
- g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, _drawningBulldozerWidth, 15);
- g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, _drawningBulldozerWidth, 15);
- g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, _drawningBulldozerWidth, 15);
- g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, _drawningBulldozerWidth, 15);
- }
-
- //blade
- if (EntityBulldozer.Blade)
- { //smth like hands?
- g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
- g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
- g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + _drawningBulldozerHeight - 18, 75, 15);
- g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + _drawningBulldozerHeight - 18, 75, 15);
- //blade itself
- g.FillRectangle(bodyBrush, _startPosX.Value + _drawningBulldozerWidth - 25, _startPosY.Value, 25, _drawningBulldozerHeight);
- g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 25, _startPosY.Value, 25, _drawningBulldozerHeight);
- g.DrawLine(pen, _startPosX.Value + _drawningBulldozerWidth - 10, _startPosY.Value, _startPosX.Value + _drawningBulldozerWidth - 10, _startPosY.Value + _drawningBulldozerHeight);
- }
}
-}
+}
\ No newline at end of file
diff --git a/ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
similarity index 98%
rename from ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs
rename to ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
index 4492883..4141c71 100644
--- a/ProjectBulldozer/ProjectBulldozer/EntityBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace ProjectBulldozer;
+namespace ProjectBulldozer.Entities;
///
/// Класс-сущность "Бульдозер"
diff --git a/ProjectBulldozer/ProjectBulldozer/Entities/EntityDozer.cs b/ProjectBulldozer/ProjectBulldozer/Entities/EntityDozer.cs
new file mode 100644
index 0000000..4000e75
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/Entities/EntityDozer.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBulldozer.Entities;
+
+///
+/// Класс-сущность "Бульдозер"
+///
+public class EntityDozer
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color AdditionalColor { get; private set; }
+
+ ///
+ /// Шаг перемещения бульдозера
+ ///
+ public double Step => Speed * 100 / Weight;
+
+ ///
+ /// Конструктор сущности
+ ///
+ ///Скорость
+ ///Вес
+ ///Основной цвет
+ ///Дополнительный цвет
+ public EntityDozer(int speed, double weight, Color bodyColor, Color additionalColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ }
+
+}
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
index efb7e9c..8a40569 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozer.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ProjectBulldozer.Drawnings;
namespace ProjectBulldozer
{
diff --git a/ProjectBulldozer/ProjectBulldozer/NewClass.cs b/ProjectBulldozer/ProjectBulldozer/NewClass.cs
new file mode 100644
index 0000000..d017313
--- /dev/null
+++ b/ProjectBulldozer/ProjectBulldozer/NewClass.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBulldozer
+{
+ internal class NewClass
+ {
+ private int closedField;
+ public double Property { private get; set; }
+ public void NewMethod()
+ {
+ //Новый метод.
+ }
+ }
+}
diff --git a/ProjectBulldozer/ProjectBulldozer/ProjectBulldozer.csproj b/ProjectBulldozer/ProjectBulldozer/ProjectBulldozer.csproj
index 13ee123..24f6cce 100644
--- a/ProjectBulldozer/ProjectBulldozer/ProjectBulldozer.csproj
+++ b/ProjectBulldozer/ProjectBulldozer/ProjectBulldozer.csproj
@@ -23,4 +23,8 @@
+
+
+
+
\ No newline at end of file