diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
index 58e332d..56f41c1 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs
@@ -14,15 +14,15 @@ namespace DoubleDeckerBus
///
/// Класс-сущность
///
- public EntityBus Bus { private set; get; }
+ public EntityBus Bus { protected set; get; }
///
/// Левая координата отрисовки автобуса
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки автобуса
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -49,6 +49,19 @@ namespace DoubleDeckerBus
{
Bus = new EntityBus(speed, weight, bodyColor);
}
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автобуса
+ /// Цвет кузова
+ /// Ширина отрисовки автобуса
+ /// Высота отрисовки автобуса
+ protected DrawningBus(int speed, float weight, Color bodyColor, int busWidth, int busHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _busWidth = busWidth;
+ _busHeight = busHeight;
+ }
///
/// Установка позиции автобуса
///
@@ -112,7 +125,7 @@ namespace DoubleDeckerBus
/// Отрисовка автобуса
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs
new file mode 100644
index 0000000..d433743
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningDoubleDeckerBus.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DoubleDeckerBus
+{
+ internal class DrawningDoubleDeckerBus : DrawningBus
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автобуса
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Признак наличия гоночной полосы
+ public DrawningDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
+ base(speed, weight, bodyColor, 112, 50)
+ {
+ Bus = new EntityDoubleDeckerBus(speed, weight, bodyColor, dopColor, bodyKit,wing, sportLine);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (Bus is not EntityDoubleDeckerBus doubleDeckerBus)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush dopBrush = new SolidBrush(doubleDeckerBus.DopColor);
+ if (doubleDeckerBus.BodyKit)
+ {
+ }
+ _startPosX += 10;
+ _startPosY += 5;
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+ if (doubleDeckerBus.SportLine)
+ {
+ }
+ if (doubleDeckerBus.Wing)
+ {
+ }
+ }
+
+ }
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
new file mode 100644
index 0000000..2869162
--- /dev/null
+++ b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DoubleDeckerBus
+{
+ internal class EntityDoubleDeckerBus : EntityBus
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия обвеса
+ ///
+ public bool BodyKit { get; private set; }
+ ///
+ /// Признак наличия антикрыла
+ ///
+ public bool Wing { get; private set; }
+ ///
+ /// Признак наличия гоночной полосы
+ ///
+ public bool SportLine { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автобуса
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Признак наличия гоночной полосы
+ public EntityDoubleDeckerBus(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ BodyKit = bodyKit;
+ Wing = wing;
+ SportLine = sportLine;
+ }
+
+ }
+}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
index 4348178..e83ef61 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
@@ -38,6 +38,7 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonCreateModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -140,11 +141,22 @@
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Location = new System.Drawing.Point(93, 393);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(104, 23);
+ this.buttonCreateModif.TabIndex = 7;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
+ //
// FormBus
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
@@ -174,5 +186,6 @@
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
index 11caede..3339d96 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs
@@ -14,6 +14,20 @@ namespace DoubleDeckerBus
_bus?.DrawTransport(gr);
pictureBoxBus.Image = bmp;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new();
+ _bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height);
+ toolStripStatusLabelSpeed.Text = $": {_bus.Bus.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_bus.Bus.Weight}";
+ toolStripStatusLabelBodyColor.Text = $":{_bus.Bus.BodyColor.Name}";
+ }
+
///
/// ""
///
@@ -28,9 +42,7 @@ namespace DoubleDeckerBus
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
pictureBoxBus.Width, pictureBoxBus.Height);
- toolStripStatusLabelSpeed.Text = $": {_bus.Bus.Speed}";
- toolStripStatusLabelWeight.Text = $": {_bus.Bus.Weight}";
- toolStripStatusLabelBodyColor.Text = $":{ _bus.Bus.BodyColor.Name}";
+ SetData();
Draw();
}
///
@@ -69,5 +81,21 @@ namespace DoubleDeckerBus
_bus?.ChangeBorders(pictureBoxBus.Width, pictureBoxBus.Height);
Draw();
}
+
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void ButtonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _bus = new DrawningDoubleDeckerBus(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,1)), Convert.ToBoolean(rnd.Next(0, 1)), Convert.ToBoolean(rnd.Next(0, 1)));
+ SetData();
+ Draw();
+ }
}
}
\ No newline at end of file