diff --git a/WarmlyLocomotive/DirectionType.cs b/WarmlyLocomotive/DirectionType.cs
new file mode 100644
index 0000000..e197473
--- /dev/null
+++ b/WarmlyLocomotive/DirectionType.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyLocomotive;
+
+public enum DirectionType
+{
+ Up = 1,
+ Down = 2,
+ Left = 3,
+ Right = 4
+}
diff --git a/WarmlyLocomotive/DrawningWarmlyLocomotive.cs b/WarmlyLocomotive/DrawningWarmlyLocomotive.cs
new file mode 100644
index 0000000..5cdc203
--- /dev/null
+++ b/WarmlyLocomotive/DrawningWarmlyLocomotive.cs
@@ -0,0 +1,182 @@
+namespace WarmlyLocomotive;
+///
+/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningWarmlyLocomotive
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityWarmlyLocomotive? EntityWarmlyLocomotive { get; private set; }
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ private int? _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ private int? _startPosY;
+ ///
+ /// Ширина прорисовки автомобиля
+ ///
+ private readonly int _drawningLocomotiveWidth = 150;
+ ///
+ /// Высота прорисовки автомобиля
+ ///
+ private readonly int _drawningLocomotiveHeight = 100;
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+
+ public void Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool tube, bool fuelTank)
+ {
+ EntityWarmlyLocomotive = new EntityWarmlyLocomotive();
+ EntityWarmlyLocomotive.Init(speed, weight, bodyColor, additionalColor,
+ tube, fuelTank);
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+ // TODO проверка, что объект "влезает" в размеры поля
+ // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
+ _pictureWidth = width;
+ _pictureHeight = height;
+ return true;
+ }
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+ // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
+ // то надо изменить координаты, чтобы он оставался в этих границах
+ _startPosX = x;
+ _startPosY = y;
+ }
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение невозможно
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityWarmlyLocomotive == null || !_startPosX.HasValue ||
+ !_startPosY.HasValue)
+ {
+ return false;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityWarmlyLocomotive.Step > 0)
+ {
+ _startPosX -= (int)EntityWarmlyLocomotive.Step;
+ }
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityWarmlyLocomotive.Step > 0)
+ {
+ _startPosY -= (int)EntityWarmlyLocomotive.Step;
+ }
+ return true;
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX.Value + EntityWarmlyLocomotive.Step < _pictureWidth)
+ {
+ _startPosX += (int)EntityWarmlyLocomotive.Step;
+ }
+ return true;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY.Value + EntityWarmlyLocomotive.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityWarmlyLocomotive.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityWarmlyLocomotive == null || !_startPosX.HasValue ||
+ !_startPosY.HasValue)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush additionalBrush = new SolidBrush(EntityWarmlyLocomotive.AdditionalColor);
+
+ //труба
+ if (EntityWarmlyLocomotive.Tube)
+ {
+ g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value, 20, 30);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 40, _startPosY.Value, 20, 40);
+ }
+
+ //локомотив
+ Brush br = new SolidBrush(EntityWarmlyLocomotive.BodyColor);
+ Brush blBr = new SolidBrush(Color.Black);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 60, 140, 20);
+ g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 60, 140, 20);
+ Point point1 = new Point(_startPosX.Value, _startPosY.Value + 60);
+ Point point2 = new Point(_startPosX.Value + 20, _startPosY.Value + 30);
+ Point point3 = new Point(_startPosX.Value + 140, _startPosY.Value + 30);
+ Point point4 = new Point(_startPosX.Value + 140, _startPosY.Value + 60);
+ Point[] body ={point1, point2, point3, point4};
+ g.DrawPolygon(pen, body);
+ g.FillPolygon(br, body);
+ g.DrawRectangle(pen, _startPosX.Value + 140, _startPosY.Value + 40, 10, 40);
+ g.FillRectangle(br, _startPosX.Value + 140, _startPosY.Value + 40, 10, 40);
+ g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 80, 20, 20);
+ g.FillEllipse(blBr, _startPosX.Value, _startPosY.Value + 80, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 80, 20, 20);
+ g.FillEllipse(blBr, _startPosX.Value + 30, _startPosY.Value + 80, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 80, 20, 20);
+ g.FillEllipse(blBr, _startPosX.Value + 90, _startPosY.Value + 80, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 120, _startPosY.Value + 80, 20, 20);
+ g.FillEllipse(blBr, _startPosX.Value + 120, _startPosY.Value + 80, 20, 20);
+
+ // отсек для топлива
+ if (EntityWarmlyLocomotive.FuelTank)
+ {
+ g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value + 40, 50, 40);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 40, 50, 40);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/WarmlyLocomotive/EntityWarmlyLocomotive.cs b/WarmlyLocomotive/EntityWarmlyLocomotive.cs
new file mode 100644
index 0000000..479b5d2
--- /dev/null
+++ b/WarmlyLocomotive/EntityWarmlyLocomotive.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyLocomotive;
+
+public class EntityWarmlyLocomotive
+{
+ 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 bool Tube { get; private set; }
+
+ public bool FuelTank { get; private set; }
+
+ public double Step => Speed * 100 / Weight;
+
+
+ public void Init(int speed, double weight, Color bodyColor, Color
+additionalColor, bool tube, bool fuelTank)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ Tube = tube;
+ FuelTank = fuelTank;
+ }
+
+}
diff --git a/WarmlyLocomotive/Form1.cs b/WarmlyLocomotive/Form1.cs
deleted file mode 100644
index 9269ed4..0000000
--- a/WarmlyLocomotive/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace WarmlyLocomotive
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/WarmlyLocomotive/Form1.Designer.cs b/WarmlyLocomotive/FormWarmlyLocomotive.Designer.cs
similarity index 54%
rename from WarmlyLocomotive/Form1.Designer.cs
rename to WarmlyLocomotive/FormWarmlyLocomotive.Designer.cs
index 8f5fc41..3d26f02 100644
--- a/WarmlyLocomotive/Form1.Designer.cs
+++ b/WarmlyLocomotive/FormWarmlyLocomotive.Designer.cs
@@ -1,14 +1,14 @@
namespace WarmlyLocomotive
{
- partial class Form1
+ partial class Тепловоз
{
///
- /// Required designer variable.
+ /// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
- /// Clean up any resources being used.
+ /// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
@@ -23,15 +23,21 @@
#region Windows Form Designer generated code
///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
+ /// 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";
+ SuspendLayout();
+ //
+ // Тепловоз
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Name = "Тепловоз";
+ Text = "FormWarmlyLocomotive";
+ ResumeLayout(false);
}
#endregion
diff --git a/WarmlyLocomotive/FormWarmlyLocomotive.cs b/WarmlyLocomotive/FormWarmlyLocomotive.cs
new file mode 100644
index 0000000..b01821c
--- /dev/null
+++ b/WarmlyLocomotive/FormWarmlyLocomotive.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace WarmlyLocomotive
+{
+ public partial class Тепловоз : Form
+ {
+ public Тепловоз()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/WarmlyLocomotive/Form1.resx b/WarmlyLocomotive/FormWarmlyLocomotive.resx
similarity index 93%
rename from WarmlyLocomotive/Form1.resx
rename to WarmlyLocomotive/FormWarmlyLocomotive.resx
index 1af7de1..af32865 100644
--- a/WarmlyLocomotive/Form1.resx
+++ b/WarmlyLocomotive/FormWarmlyLocomotive.resx
@@ -1,17 +1,17 @@
-