diff --git a/AirBomber/AirBomber/DrawningSportJet.cs b/AirBomber/AirBomber/DrawningSportJet.cs
new file mode 100644
index 0000000..840e102
--- /dev/null
+++ b/AirBomber/AirBomber/DrawningSportJet.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirBomber
+{
+
+ internal class DrawningSportJet : DrawningJet
+ {
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Цвет
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ ///
+ public DrawningSportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
+ base(speed, weight, bodyColor, 110, 60)
+ {
+ Jet = new EntitySportJet(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (Jet is not EntitySportJet sportJet)
+ {
+ return;
+ }
+
+ Pen pen = new Pen(Color.Black);
+ Brush dopBrush = new SolidBrush(sportJet.DopColor);
+ int x = Convert.ToInt32(_startPosX);
+ int y = Convert.ToInt32(_startPosY);
+
+ if (sportJet.Wing)
+ {
+ GraphicsPath path1 = new GraphicsPath();
+ Point pt1 = new Point(x + 100, y + 10);
+ Point pt2 = new Point(x + 100, y + 40);
+ Rectangle rect1 = new Rectangle(x + 80, y + 10, 30, 30);
+
+ path1.AddLine(pt1, pt2);
+ path1.AddArc(rect1, 90, 180);
+ g.DrawPath(pen, path1);
+ g.FillPath(dopBrush, path1);
+
+ GraphicsPath path2 = new GraphicsPath();
+ Point pt3 = new Point(x + 100, y + 80);
+ Point pt4 = new Point(x + 100, y + 110);
+ Rectangle rect2 = new Rectangle(x + 80, y + 80, 30, 30);
+
+ path2.AddLine(pt3, pt4);
+ path2.AddArc(rect2, 90, 180);
+ g.DrawPath(pen, path2);
+ g.FillPath(dopBrush, path2);
+ }
+ if (sportJet.SportLine) { }
+
+ _startPosX += 10;
+ _startPosY += 5;
+ base.DrawTransport(g);
+ _startPosX -= 10;
+ _startPosY -= 5;
+
+ if (sportJet.BodyKit)
+ {
+ Rectangle rect = new Rectangle(x + 146, y + 45, 10, 40);
+ g.DrawRectangle(pen, rect);
+ g.FillRectangle(dopBrush, rect);
+ Point pt5 = new Point(x + 30, y + 65);
+ Point pt6 = new Point(x + 145, y + 65);
+ g.DrawLine(pen, pt5, pt6);
+ }
+ }
+ }
+}
diff --git a/AirBomber/AirBomber/EntitySportJet.cs b/AirBomber/AirBomber/EntitySportJet.cs
new file mode 100644
index 0000000..6127a16
--- /dev/null
+++ b/AirBomber/AirBomber/EntitySportJet.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirBomber
+{
+ internal class EntitySportJet : EntityJet
+ {
+ ///
+ ///Класс-сущность "Спортивный автомобиль"
+ ///
+ 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 EntitySportJet(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/AirBomber/AirBomber/WarJet.Designer.cs b/AirBomber/AirBomber/WarJet.Designer.cs
index e07e3da..d476ade 100644
--- a/AirBomber/AirBomber/WarJet.Designer.cs
+++ b/AirBomber/AirBomber/WarJet.Designer.cs
@@ -28,7 +28,7 @@
///
private void InitializeComponent()
{
- this.pictureBoxCar = new System.Windows.Forms.PictureBox();
+ this.pictureBoxJet = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
@@ -38,20 +38,21 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
+ this.buttonCreateModif = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
- // pictureBoxCar
+ // pictureBoxJet
//
- this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxCar.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxCar.Name = "pictureBoxCar";
- this.pictureBoxCar.Size = new System.Drawing.Size(800, 428);
- this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxCar.TabIndex = 0;
- this.pictureBoxCar.TabStop = false;
- this.pictureBoxCar.Click += new System.EventHandler(this.PictureBoxCar_Resize);
+ this.pictureBoxJet.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxJet.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxJet.Name = "pictureBoxJet";
+ this.pictureBoxJet.Size = new System.Drawing.Size(800, 450);
+ this.pictureBoxJet.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxJet.TabIndex = 0;
+ this.pictureBoxJet.TabStop = false;
+ this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxCar_Resize);
//
// statusStrip1
//
@@ -142,21 +143,32 @@
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Location = new System.Drawing.Point(93, 402);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(107, 23);
+ this.buttonCreateModif.TabIndex = 7;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
+ //
// WarJet
//
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.buttonDown);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
- this.Controls.Add(this.pictureBoxCar);
this.Controls.Add(this.statusStrip1);
+ this.Controls.Add(this.pictureBoxJet);
this.Name = "WarJet";
this.Text = "Военный самолет";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
@@ -166,7 +178,7 @@
#endregion
- private PictureBox pictureBoxCar;
+ private PictureBox pictureBoxJet;
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
@@ -176,5 +188,6 @@
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/AirBomber/AirBomber/WarJet.cs b/AirBomber/AirBomber/WarJet.cs
index 9f2fd7d..a0d81b4 100644
--- a/AirBomber/AirBomber/WarJet.cs
+++ b/AirBomber/AirBomber/WarJet.cs
@@ -12,12 +12,22 @@ namespace AirBomber
///
private void Draw()
{
- Bitmap bmp = new Bitmap(pictureBoxCar.Width, pictureBoxCar.Height);
+ Bitmap bmp = new Bitmap(pictureBoxJet.Width, pictureBoxJet.Height);
Graphics gr = Graphics.FromImage(bmp);
_jet?.DrawTransport(gr);
- pictureBoxCar.Image = bmp;
+ pictureBoxJet.Image = bmp;
+ }
+ ///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new Random();
+ _jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
+ toolStripStatusLabelSpeed.Text = $": {_jet.Jet.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_jet.Jet.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_jet.Jet.BodyColor.Name}";
}
-
private void buttonMove_Click(object sender, EventArgs e)
{
//
@@ -46,7 +56,7 @@ namespace AirBomber
///
private void PictureBoxCar_Resize(object sender, EventArgs e)
{
- _jet?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height);
+ _jet?.ChangeBorders(pictureBoxJet.Width, pictureBoxJet.Height);
Draw();
}
///
@@ -58,10 +68,19 @@ namespace AirBomber
{
Random rnd = new Random();
_jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
- toolStripStatusLabelSpeed.Text = $": {_jet.Jet.Speed}";
- toolStripStatusLabelWeight.Text = $": {_jet.Jet.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {_jet.Jet.BodyColor.Name}";
+ _jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
+ SetData();
+ Draw();
+ }
+
+ private void buttonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new Random();
+ var jet = new DrawningSportJet(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();
}
}