diff --git a/WarmlyShip/WarmlyShip/DrawningLiner.cs b/WarmlyShip/WarmlyShip/DrawningLiner.cs
new file mode 100644
index 0000000..77bb230
--- /dev/null
+++ b/WarmlyShip/WarmlyShip/DrawningLiner.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyShip
+{
+ ///
+ /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+ ///
+ internal class DrawningLiner : DrawningShip
+ {
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес корабля
+ /// Цвет палубы
+ /// Дополнительный цвет
+ /// Признак наличия бассейна
+ /// Признак наличия дополнительной палубы
+ public DrawningLiner(int speed, float weight, Color bodyColor, Color dopColor, bool swimmingPool, bool dopDeck) :
+ base(speed, weight, bodyColor, 110, 60)
+ {
+ Ship = new EntityLiner(speed, weight, bodyColor, dopColor, swimmingPool, dopDeck);
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if (Ship is not EntityLiner liner)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Brush dopBrush = new SolidBrush(liner.DopColor);
+
+ if (liner.DopDeck)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 45, _startPosY, 35, 15);
+ g.DrawRectangle(pen, _startPosX + 45, _startPosY, 35, 15);
+ }
+
+ _startPosY += 10;
+ base.DrawTransport(g);
+ _startPosY -= 10;
+
+ if (liner.SwimmingPool)
+ {
+ g.FillRectangle(dopBrush, _startPosX + 25, _startPosY + 15, 15, 7);
+ g.DrawRectangle(pen, _startPosX + 25, _startPosY + 15, 15, 7);
+ }
+
+ }
+ }
+}
diff --git a/WarmlyShip/WarmlyShip/DrawningShip.cs b/WarmlyShip/WarmlyShip/DrawningShip.cs
index 910fb29..99b4e42 100644
--- a/WarmlyShip/WarmlyShip/DrawningShip.cs
+++ b/WarmlyShip/WarmlyShip/DrawningShip.cs
@@ -14,15 +14,15 @@ namespace WarmlyShip
/// >
/// Класс-сущность
///
- public EntityShip Ship { get; private set; }
+ public EntityShip Ship { get; protected set; }
///
/// Левая координата отрисовки корабля
///
- private float _startPosX;
+ protected float _startPosX;
///
/// Верхняя кооридната отрисовки корабля
///
- private float _startPosY;
+ protected float _startPosY;
///
/// Ширина окна отрисовки
///
@@ -49,7 +49,20 @@ namespace WarmlyShip
{
Ship = new EntityShip(speed, weight, bodyColor);
}
-
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес корабля
+ /// Цвет палубы
+ /// Ширина отрисовки корабля
+ /// Высота отрисовки корабля
+ protected DrawningShip(int speed, float weight, Color bodyColor, int shipWidth, int shipHeight) :
+ this(speed, weight, bodyColor)
+ {
+ _shipWidth = shipWidth;
+ _shipHeight = shipHeight;
+ }
///
/// Установка позиции корабля
///
@@ -116,7 +129,7 @@ namespace WarmlyShip
/// Отрисовка корабля
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
diff --git a/WarmlyShip/WarmlyShip/EntityLiner.cs b/WarmlyShip/WarmlyShip/EntityLiner.cs
new file mode 100644
index 0000000..7c2cc14
--- /dev/null
+++ b/WarmlyShip/WarmlyShip/EntityLiner.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WarmlyShip
+{
+ ///
+ /// Класс-сущность "Лайнер"
+ ///
+ internal class EntityLiner : EntityShip
+ {
+ ///
+ /// Дополнительный цвет
+ ///
+ public Color DopColor { get; private set; }
+ ///
+ /// Признак наличия бассейна
+ ///
+ public bool SwimmingPool { get; private set; }
+ ///
+ /// Признак наличия дополнительной палубы
+ ///
+ public bool DopDeck { get; private set; }
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес корабля
+ /// Цвет палубы
+ /// Дополнительный цвет
+ /// Признак наличия бассейна
+ /// Признак наличия дополнительной палубы
+ public EntityLiner(int speed, float weight, Color bodyColor, Color dopColor, bool swimmingPool, bool dopDeck) :
+ base(speed, weight, bodyColor)
+ {
+ DopColor = dopColor;
+ SwimmingPool = swimmingPool;
+ DopDeck = dopDeck;
+ }
+
+ }
+}
diff --git a/WarmlyShip/WarmlyShip/FormShip.Designer.cs b/WarmlyShip/WarmlyShip/FormShip.Designer.cs
index 8f471d2..a7d1bc9 100644
--- a/WarmlyShip/WarmlyShip/FormShip.Designer.cs
+++ b/WarmlyShip/WarmlyShip/FormShip.Designer.cs
@@ -38,6 +38,7 @@
this.buttonUp = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonCreateModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -51,7 +52,6 @@
this.pictureBoxShip.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxShip.TabIndex = 0;
this.pictureBoxShip.TabStop = false;
- this.pictureBoxShip.Click += new System.EventHandler(this.ButtonMove_Click);
//
// statusStrip1
//
@@ -143,11 +143,22 @@
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Location = new System.Drawing.Point(93, 403);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(110, 23);
+ this.buttonCreateModif.TabIndex = 7;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
+ //
// FormShip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(824, 462);
+ this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonUp);
@@ -177,5 +188,6 @@
private Button buttonUp;
private Button buttonRight;
private Button buttonLeft;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/WarmlyShip/WarmlyShip/FormShip.cs b/WarmlyShip/WarmlyShip/FormShip.cs
index 1ee0920..275a2eb 100644
--- a/WarmlyShip/WarmlyShip/FormShip.cs
+++ b/WarmlyShip/WarmlyShip/FormShip.cs
@@ -21,6 +21,17 @@ namespace WarmlyShip
pictureBoxShip.Image = bmp;
}
///
+ ///
+ ///
+ private void SetData()
+ {
+ Random rnd = new();
+ _ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height);
+ toolStripStatusLabelSpeed.Text = $": {_ship.Ship.Speed}";
+ toolStripStatusLabelWeight.Text = $": {_ship.Ship.Weight}";
+ toolStripStatusLabelBodyColor.Text = $": {_ship.Ship.BodyColor.Name}";
+ }
+ ///
/// ""
///
///
@@ -29,10 +40,7 @@ namespace WarmlyShip
{
Random rnd = new();
_ship = new DrawningShip(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height);
- toolStripStatusLabelSpeed.Text = $": {_ship.Ship.Speed}";
- toolStripStatusLabelWeight.Text = $": {_ship.Ship.Weight}";
- toolStripStatusLabelBodyColor.Text = $": {_ship.Ship.BodyColor.Name}";
+ SetData();
Draw();
}
///
@@ -71,5 +79,20 @@ namespace WarmlyShip
_ship?.ChangeBorders(pictureBoxShip.Width, pictureBoxShip.Height);
Draw();
}
+
+ ///
+ /// ""
+ ///
+ ///
+ ///
+ private void ButtonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _ship = new DrawningLiner(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
diff --git a/WarmlyShip/WarmlyShip/FormShip.resx b/WarmlyShip/WarmlyShip/FormShip.resx
index 5cb320f..54823c3 100644
--- a/WarmlyShip/WarmlyShip/FormShip.resx
+++ b/WarmlyShip/WarmlyShip/FormShip.resx
@@ -60,4 +60,7 @@
17, 17
+
+ 63
+
\ No newline at end of file