diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
index 2ded9de..26e50e6 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/DrawingAirplane.cs
@@ -9,15 +9,15 @@ namespace AirplaneWithRadar
///
/// Класс-сущность
///
- public EntityAirplane Airplane { private set; get; }
+ public EntityAirplane Airplane { protected set; get; }
///
/// Левая координата отрисовки самолёта
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки самолёта
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -40,11 +40,27 @@ namespace AirplaneWithRadar
/// Скорость
/// Вес
/// Цвет
- public void Init(int speed, float weight, Color bodyColor)
+ public DrawningAirplane(int speed, float weight, Color bodyColor)
{
- Airplane = new EntityAirplane();
- Airplane.Init(speed, weight, bodyColor);
+ Airplane = new EntityAirplane(speed, weight, bodyColor);
}
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес самолёта
+ /// Цвет кузова
+ /// Ширина отрисовки самолёта
+ /// Высота отрисовки самолёта
+ protected DrawningAirplane(int speed, float weight, Color bodyColor, int
+ airplaneWidth, int airplaneHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _airplaneWidth = airplaneWidth;
+ _airplaneHeight = airplaneHeight;
+ }
+
///
/// Установка позиции
///
@@ -52,6 +68,7 @@ namespace AirplaneWithRadar
/// Координата Y
/// Ширина картинки
/// Высота картинки
+
public void SetPosition(int x, int y, int width, int height)
{
_startPosX = x;
@@ -111,7 +128,7 @@ namespace AirplaneWithRadar
/// Отрисовка самолёта
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs
new file mode 100644
index 0000000..a44612d
--- /dev/null
+++ b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+
+namespace AirplaneWithRadar
+{
+ internal class DrawningAirplaneWithRadar : DrawningAirplane
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия радара
+ /// Признак наличия дополнительных топливных баков
+ public DrawningAirplaneWithRadar(int speed, float weight, Color bodyColor, Color
+dopColor, bool radar, bool fuelTanks) :
+ base(speed, weight, bodyColor, 100, 10)
+ {
+ Airplane = new EntityAirplaneWithRadar(speed, weight, bodyColor, dopColor, radar, fuelTanks);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (Airplane is not EntityAirplaneWithRadar airplaneWithRadar)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush dopBrush = new SolidBrush(airplaneWithRadar.DopColor);
+ if (airplaneWithRadar.Radar)
+ {
+ g.FillEllipse(dopBrush, _startPosX + 40, _startPosY, 20, 5);
+ g.DrawLine(pen, _startPosX + 43, _startPosY + 4, _startPosX + 43, _startPosY + 7);
+ g.DrawLine(pen, _startPosX + 57, _startPosY + 4, _startPosX + 57, _startPosY + 7);
+ }
+ _startPosX += 10;
+ _startPosY += 5;
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+ if (airplaneWithRadar.FuelTanks)
+ {
+ g.FillEllipse(dopBrush, _startPosX + 35, _startPosY + 13, 30, 5);
+ }
+ }
+ }
+}
diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs
index ef80d96..4682efc 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs
@@ -29,7 +29,7 @@ namespace AirplaneWithRadar
///
///
///
- public void Init(int speed, float weight, Color bodyColor)
+ public EntityAirplane(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs
new file mode 100644
index 0000000..3ce6d0d
--- /dev/null
+++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirplaneWithRadar
+{
+ internal class EntityAirplaneWithRadar : EntityAirplane
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия радара
+ ///
+ public bool Radar { get; private set; }
+ ///
+ /// Признак наличия дополнительного топливного бака
+ ///
+ public bool FuelTanks { get; private set; }
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес самолёта
+ /// Цвет кузова
+ /// Дополнительный цвет
+ /// Признак наличия радара
+ /// Признак наличия дополнительных топливных баков
+ public EntityAirplaneWithRadar(int speed, float weight, Color bodyColor, Color
+ dopColor, bool radar, bool fuelTanks) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ Radar = radar;
+ FuelTanks = fuelTanks;
+ }
+ }
+}
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs
index 5cd3dbb..b0dc9d2 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.Designer.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.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();
this.statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.SuspendLayout();
@@ -89,7 +90,7 @@
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreate.Location = new System.Drawing.Point(12, 395);
this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(75, 23);
+ this.buttonCreate.Size = new System.Drawing.Size(96, 23);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
@@ -143,11 +144,22 @@
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Location = new System.Drawing.Point(12, 366);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(96, 23);
+ this.buttonCreateModif.TabIndex = 7;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
+ //
// FormAirplane
//
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);
@@ -177,5 +189,6 @@
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
index 3be033f..bc1643b 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormAirplane.cs
@@ -9,14 +9,15 @@ namespace AirplaneWithRadar
InitializeComponent();
}
- ///
- ///
- ///
private void pictureBoxAirplane_Click(object sender, EventArgs e)
{
}
+
+ ///
+ ///
+ ///
private void Draw()
{
Bitmap bmp = new(pictureBoxAirplane.Width, pictureBoxAirplane.Height);
@@ -24,22 +25,30 @@ namespace AirplaneWithRadar
_airplane?.DrawTransport(gr);
pictureBoxAirplane.Image = bmp;
}
+
+ ///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new();
+ _airplane.SetPosition(rnd.Next(20, 100), rnd.Next(20, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
+ toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}";
+ }
+
///
/// ""
///
///
///
///
-
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _airplane = new DrawningAirplane();
- _airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _airplane.SetPosition(rnd.Next(20, 100), rnd.Next(20, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
- toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}";
- toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}";
+ _airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ SetData();
Draw();
}
@@ -79,5 +88,22 @@ namespace AirplaneWithRadar
_airplane?.ChangeBorders(pictureBoxAirplane.Width, pictureBoxAirplane.Height);
Draw();
}
+
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void buttonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _airplane = new DrawningAirplaneWithRadar(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)));
+ SetData();
+ Draw();
+ }
}
}
\ No newline at end of file