diff --git a/ProjectMachine/ProjectMachine/DrawningMachine.cs b/ProjectMachine/ProjectMachine/DrawningMachine.cs
index e76dddc..be3f5b6 100644
--- a/ProjectMachine/ProjectMachine/DrawningMachine.cs
+++ b/ProjectMachine/ProjectMachine/DrawningMachine.cs
@@ -14,15 +14,15 @@ namespace ProjectMachine
///
/// Класс-сущность
///
- public EntityMachine Machine { get; private set; }
+ public EntityMachine Machine { get; protected set; }
///
/// Левая координата отрисовки машины
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки машины
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -56,6 +56,13 @@ namespace ProjectMachine
/// Координата Y
/// Ширина картинки
/// Высота картинки
+ protected DrawningMachine(int speed, float weight, Color bodyColor, int machineWidth, int machineHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _machineWidth = machineWidth;
+ _machineHeight = machineHeight;
+ }
+
public void SetPosition(int x, int y, int width, int height)
{
if (x < 0 || y < 0 || x + _machineWidth > width || y + _machineHeight > height)
@@ -113,7 +120,7 @@ namespace ProjectMachine
/// Отрисовка машины
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
diff --git a/ProjectMachine/ProjectMachine/DrawningTank.cs b/ProjectMachine/ProjectMachine/DrawningTank.cs
new file mode 100644
index 0000000..baa6ee6
--- /dev/null
+++ b/ProjectMachine/ProjectMachine/DrawningTank.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectMachine
+{
+ internal class DrawningTank : DrawningMachine
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия башни с орудием
+ /// Признак наличия зенитного пулемета
+ public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) :
+ base(speed, weight, bodyColor, 110, 60)
+ {
+ Machine = new EntityTank(speed, weight, bodyColor, dopColor, bodyKit, turret, gun);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (Machine is not EntityTank tank)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush dopBrush = new SolidBrush(tank.DopColor);
+
+ if (tank.BodyKit)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 45, _startPosY, 20, 10);
+ g.DrawLine(pen, _startPosX + 65, _startPosY + 2, _startPosX + 85, _startPosY + 2);
+ }
+
+ if (tank.Turret)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 45, _startPosY, 20, 10);
+ }
+
+ _startPosX += 10;
+ _startPosY += 5;
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+ }
+ }
+}
diff --git a/ProjectMachine/ProjectMachine/EntityTank.cs b/ProjectMachine/ProjectMachine/EntityTank.cs
new file mode 100644
index 0000000..342293a
--- /dev/null
+++ b/ProjectMachine/ProjectMachine/EntityTank.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectMachine
+{
+ ///
+ /// Класс-сущность "Танк"
+ ///
+ internal class EntityTank : EntityMachine
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия обвеса
+ ///
+ public bool BodyKit { get; private set; }
+ ///
+ /// Признак наличия башни с орудием
+ ///
+ public bool Turret { get; private set; }
+ ///
+ /// Признак наличия зенитного пулемета
+ ///
+ public bool Gun { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// /// Признак наличия обвеса
+ /// Признак наличия башни с орудием
+ /// Признак наличия зенитного пулемета
+ public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ BodyKit = bodyKit;
+ Turret = turret;
+ Gun = gun;
+ }
+
+ }
+}
diff --git a/ProjectMachine/ProjectMachine/FormMachine.Designer.cs b/ProjectMachine/ProjectMachine/FormMachine.Designer.cs
index 5ed5e6b..f7e8390 100644
--- a/ProjectMachine/ProjectMachine/FormMachine.Designer.cs
+++ b/ProjectMachine/ProjectMachine/FormMachine.Designer.cs
@@ -38,6 +38,7 @@
this.buttonRight = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonCreateModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMachine)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -148,11 +149,22 @@
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Location = new System.Drawing.Point(124, 385);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(130, 29);
+ this.buttonCreateModif.TabIndex = 7;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
+ //
// FormMachine
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(733, 453);
+ this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonRight);
@@ -182,5 +194,6 @@
private Button buttonRight;
private Button buttonUp;
private Button buttonLeft;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/ProjectMachine/ProjectMachine/FormMachine.cs b/ProjectMachine/ProjectMachine/FormMachine.cs
index 934d710..8973582 100644
--- a/ProjectMachine/ProjectMachine/FormMachine.cs
+++ b/ProjectMachine/ProjectMachine/FormMachine.cs
@@ -19,6 +19,17 @@ namespace ProjectMachine
pictureBoxMachine.Image = bmp;
}
///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new();
+ _machine.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxMachine.Width, pictureBoxMachine.Height);
+ toolStripStatusLabelSpeed.Text = $": {_machine.Machine.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_machine.Machine.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_machine.Machine.BodyColor.Name}";
+ }
+ ///
/// ""
///
///
@@ -27,10 +38,7 @@ namespace ProjectMachine
{
Random rnd = new();
_machine = new DrawningMachine(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _machine.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxMachine.Width, pictureBoxMachine.Height);
- toolStripStatusLabelSpeed.Text = $": {_machine.Machine.Speed}";
- toolStripStatusLabelWeight.Text = $": {_machine.Machine.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {_machine.Machine.BodyColor.Name}";
+ SetData();
Draw();
}
///
@@ -69,5 +77,17 @@ namespace ProjectMachine
_machine?.ChangeBorders(pictureBoxMachine.Width, pictureBoxMachine.Height);
Draw();
}
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void ButtonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _machine = new DrawningTank(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
+ SetData();
+ Draw();
+ }
}
}
\ No newline at end of file