diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs
index 26b123c..8c79154 100644
--- a/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs
+++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs
@@ -5,7 +5,7 @@ namespace ProjectLiner.Drawnings;
///
/// Класс-прорисовка сущности "Лайнер"
///
-public class DrawningLiner : DrawningSmallLiner
+public class DrawningLiner : DrawningShip
{
///
/// Конструктор
@@ -18,12 +18,12 @@ public class DrawningLiner : DrawningSmallLiner
/// Наличие басейна
public DrawningLiner(int speed, double weight, Color bodyColor, Color additionalColor, bool secondDeck, bool pool) : base(150, 65)
{
- EntitySmallLiner = new EntityLiner(speed, weight, bodyColor, additionalColor, secondDeck, pool);
+ EntityShip = new EntityLiner(speed, weight, bodyColor, additionalColor, secondDeck, pool);
}
public override void DrawTransport(Graphics g)
{
- if (EntitySmallLiner == null || EntitySmallLiner is not EntityLiner Liner || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityShip == null || EntityShip is not EntityLiner Liner || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningSmallLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningShip.cs
similarity index 82%
rename from ProjectLiner/ProjectLiner/Drawnings/DrawningSmallLiner.cs
rename to ProjectLiner/ProjectLiner/Drawnings/DrawningShip.cs
index 0d9f151..8181a2b 100644
--- a/ProjectLiner/ProjectLiner/Drawnings/DrawningSmallLiner.cs
+++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningShip.cs
@@ -5,12 +5,12 @@ namespace ProjectLiner.Drawnings;
///
/// Класс, отвечающий за прорисовку и перемещение базового объкта-сущности
///
-public class DrawningSmallLiner
+public class DrawningShip
{
///
- /// Класс-сущность "Маленький Лайнер"
+ /// Класс-сущность "Корабль"
///
- public EntitySmallLiner? EntitySmallLiner { get; protected set; }
+ public EntityShip? EntityShip { get; protected set; }
///
/// Ширина окна
@@ -23,22 +23,22 @@ public class DrawningSmallLiner
private int? _pictureHeight;
///
- /// Левая координата прорисовки сущности "Лайнер"
+ /// Левая координата прорисовки сущности
///
protected int? _startPosX;
///
- /// Верхнаяя координата прорисовки сущности "Лайнер"
+ /// Верхнаяя координата прорисовки сущности
///
protected int? _startPosY;
///
- /// Ширина прорисовки сущности "Лайнер"
+ /// Ширина прорисовки сущности
///
private readonly int _drawningLinerWidth = 150;
///
- /// Высота прорисовки сущности "Лайнер"
+ /// Высота прорисовки сущности
///
private readonly int _drawningLinerHeight = 50;
@@ -65,9 +65,8 @@ public class DrawningSmallLiner
///
/// Пустой конструктор
///
- private DrawningSmallLiner()
+ private DrawningShip()
{
-
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
@@ -80,17 +79,17 @@ public class DrawningSmallLiner
/// Скорость
/// Вес
/// Основной цвет
- public DrawningSmallLiner(int speed, double weight, Color bodyColor) : this()
+ public DrawningShip(int speed, double weight, Color bodyColor) : this()
{
- EntitySmallLiner = new EntitySmallLiner(speed, weight, bodyColor);
+ EntityShip = new EntityShip(speed, weight, bodyColor);
}
///
/// Конструктор для наследников
///
- /// Ширина прорисовки сущности "Маленький Лайнер"
- /// Высота прорисовки сущности "Маленький Лайнер"
- protected DrawningSmallLiner(int drawningLinerWidth, int drawningLinerHeight) : this()
+ /// Ширина прорисовки сущности "Корабль"
+ /// Высота прорисовки сущности "Корабль"
+ protected DrawningShip(int drawningLinerWidth, int drawningLinerHeight) : this()
{
_drawningLinerWidth = drawningLinerWidth;
_drawningLinerHeight = drawningLinerHeight;
@@ -151,7 +150,7 @@ public class DrawningSmallLiner
/// true - перемещение выполнено, false - перемещение невозможно
public bool MoveTransport(DirectionType direction)
{
- if (EntitySmallLiner == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
@@ -159,31 +158,31 @@ public class DrawningSmallLiner
{
// Влево
case DirectionType.Left:
- if (_startPosX.Value - EntitySmallLiner.Step > 0)
+ if (_startPosX.Value - EntityShip.Step > 0)
{
- _startPosX -= (int)EntitySmallLiner.Step;
+ _startPosX -= (int)EntityShip.Step;
}
return true;
// Вверх
case DirectionType.Up:
- if (_startPosY.Value - EntitySmallLiner.Step > 0)
+ if (_startPosY.Value - EntityShip.Step > 0)
{
- _startPosY -= (int)EntitySmallLiner.Step;
+ _startPosY -= (int)EntityShip.Step;
}
return true;
// Вправо
case DirectionType.Right:
- if (_startPosX.Value + _drawningLinerWidth + EntitySmallLiner.Step < _pictureWidth.Value)
+ if (_startPosX.Value + _drawningLinerWidth + EntityShip.Step < _pictureWidth.Value)
{
- _startPosX += (int)EntitySmallLiner.Step;
+ _startPosX += (int)EntityShip.Step;
}
return true;
// Вниз
case DirectionType.Down:
- if (_startPosY.Value + _drawningLinerHeight + EntitySmallLiner.Step < _pictureHeight.Value)
+ if (_startPosY.Value + _drawningLinerHeight + EntityShip.Step < _pictureHeight.Value)
{
- _startPosY += (int)EntitySmallLiner.Step;
+ _startPosY += (int)EntityShip.Step;
}
return true;
default:
@@ -197,12 +196,12 @@ public class DrawningSmallLiner
///
public virtual void DrawTransport(Graphics g)
{
- if (EntitySmallLiner == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black, 2);
- Brush br = new SolidBrush(EntitySmallLiner.BodyColor);
+ Brush br = new SolidBrush(EntityShip.BodyColor);
// Корпус и палуба Лайнера
g.FillPolygon(br, new[]
diff --git a/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs
index 35426c8..facc940 100644
--- a/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs
+++ b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs
@@ -3,7 +3,7 @@
///
/// Класс-сущность "Лайнер"
///
-public class EntityLiner : EntitySmallLiner
+public class EntityLiner : EntityShip
{
///
/// Дополнительный цвет
diff --git a/ProjectLiner/ProjectLiner/Entities/EntitySmallLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityShip.cs
similarity index 76%
rename from ProjectLiner/ProjectLiner/Entities/EntitySmallLiner.cs
rename to ProjectLiner/ProjectLiner/Entities/EntityShip.cs
index e98142e..9504427 100644
--- a/ProjectLiner/ProjectLiner/Entities/EntitySmallLiner.cs
+++ b/ProjectLiner/ProjectLiner/Entities/EntityShip.cs
@@ -1,9 +1,9 @@
namespace ProjectLiner.Entities;
///
-/// Класс-сущность "Маленький Лайнер"
+/// Класс-сущность "Корабль"
///
-public class EntitySmallLiner
+public class EntityShip
{
///
/// Скорость
@@ -26,12 +26,12 @@ public class EntitySmallLiner
public double Step => Speed * 100 / Weight;
///
- /// Конструктор сущности "Маленький Лайнер"
+ /// Конструктор сущности "Корабль"
///
/// Скорость
/// Вес
/// Основой цвет
- public EntitySmallLiner(int speed, double weight, Color bodyColor)
+ public EntityShip(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs
index 0d6ebfc..a5b99c9 100644
--- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs
+++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs
@@ -29,7 +29,7 @@
private void InitializeComponent()
{
pictureBoxLiner = new PictureBox();
- buttonCreateSmallLiner = new Button();
+ buttonCreateShip = new Button();
buttonRight = new Button();
buttonDown = new Button();
buttonLeft = new Button();
@@ -49,16 +49,16 @@
pictureBoxLiner.TabIndex = 0;
pictureBoxLiner.TabStop = false;
//
- // buttonCreateSmallLiner
+ // buttonCreateShip
//
- buttonCreateSmallLiner.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreateSmallLiner.Location = new Point(12, 426);
- buttonCreateSmallLiner.Name = "buttonCreateSmallLiner";
- buttonCreateSmallLiner.Size = new Size(154, 23);
- buttonCreateSmallLiner.TabIndex = 1;
- buttonCreateSmallLiner.Text = "Создать малый лайнер";
- buttonCreateSmallLiner.UseVisualStyleBackColor = true;
- buttonCreateSmallLiner.Click += ButtonCreateSmallLiner_Click;
+ buttonCreateShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateShip.Location = new Point(12, 426);
+ buttonCreateShip.Name = "buttonCreateShip";
+ buttonCreateShip.Size = new Size(154, 23);
+ buttonCreateShip.TabIndex = 1;
+ buttonCreateShip.Text = "Создать корабль";
+ buttonCreateShip.UseVisualStyleBackColor = true;
+ buttonCreateShip.Click += ButtonCreateShip_Click;
//
// buttonRight
//
@@ -151,7 +151,7 @@
Controls.Add(buttonLeft);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
- Controls.Add(buttonCreateSmallLiner);
+ Controls.Add(buttonCreateShip);
Controls.Add(pictureBoxLiner);
Name = "FormLiner";
StartPosition = FormStartPosition.CenterScreen;
@@ -163,7 +163,7 @@
#endregion
private PictureBox pictureBoxLiner;
- private Button buttonCreateSmallLiner;
+ private Button buttonCreateShip;
private Button buttonRight;
private Button buttonDown;
private Button buttonLeft;
diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs
index ac0ee1b..99c5601 100644
--- a/ProjectLiner/ProjectLiner/FormLiner.cs
+++ b/ProjectLiner/ProjectLiner/FormLiner.cs
@@ -11,7 +11,7 @@ public partial class FormLiner : Form
///
/// Поле-объект для прорисовки объекта
///
- private DrawningSmallLiner? _drawningSmallLiner;
+ private DrawningShip? _drawningShip;
///
/// Стратегия перемещения
@@ -32,14 +32,14 @@ public partial class FormLiner : Form
///
private void Draw()
{
- if (_drawningSmallLiner == null)
+ if (_drawningShip == null)
{
return;
}
Bitmap bmp = new(pictureBoxLiner.Width,
pictureBoxLiner.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningSmallLiner.DrawTransport(gr);
+ _drawningShip.DrawTransport(gr);
pictureBoxLiner.Image = bmp;
}
@@ -52,13 +52,13 @@ public partial class FormLiner : Form
Random random = new();
switch (type)
{
- case nameof(DrawningSmallLiner):
- _drawningSmallLiner = new DrawningSmallLiner(
+ case nameof(DrawningShip):
+ _drawningShip = new DrawningShip(
random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawningLiner):
- _drawningSmallLiner = new DrawningLiner(
+ _drawningShip = new DrawningLiner(
random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
@@ -68,8 +68,8 @@ public partial class FormLiner : Form
default:
return;
}
- _drawningSmallLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height);
- _drawningSmallLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ _drawningShip.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height);
+ _drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
@@ -83,11 +83,11 @@ public partial class FormLiner : Form
private void ButtonCreateLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner));
///
- /// Обработка нажатия кнопки "Создать малый лайнер"
+ /// Обработка нажатия кнопки "Создать корабль"
///
///
///
- private void ButtonCreateSmallLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSmallLiner));
+ private void ButtonCreateShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip));
///
/// Обработка нажатия кнопок навигации движения
@@ -96,7 +96,7 @@ public partial class FormLiner : Form
///
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningSmallLiner == null)
+ if (_drawningShip == null)
{
return;
}
@@ -105,16 +105,16 @@ public partial class FormLiner : Form
switch (name)
{
case "buttonUp":
- result = _drawningSmallLiner.MoveTransport(DirectionType.Up);
+ result = _drawningShip.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
- result = _drawningSmallLiner.MoveTransport(DirectionType.Down);
+ result = _drawningShip.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
- result = _drawningSmallLiner.MoveTransport(DirectionType.Left);
+ result = _drawningShip.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
- result = _drawningSmallLiner.MoveTransport(DirectionType.Right);
+ result = _drawningShip.MoveTransport(DirectionType.Right);
break;
}
if (result)
@@ -130,7 +130,7 @@ public partial class FormLiner : Form
///
private void ButtonStrategyStep_Click(object sender, EventArgs e)
{
- if (_drawningSmallLiner == null)
+ if (_drawningShip == null)
{
return;
}
@@ -149,7 +149,7 @@ public partial class FormLiner : Form
return;
}
- _strategy.SetData(new MoveableLiner(_drawningSmallLiner),
+ _strategy.SetData(new MoveableLiner(_drawningShip),
pictureBoxLiner.Width, pictureBoxLiner.Height);
}
diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs
index b3e7f58..d33e0e0 100644
--- a/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs
+++ b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs
@@ -3,47 +3,47 @@
namespace ProjectLiner.MovementStrategy;
///
-/// Класс-реализация IMoveableObject с использованием drawningSmallLiner
+/// Класс-реализация IMoveableObject с использованием drawningShip
///
public class MoveableLiner : IMoveableObject
{
///
- /// Поле-объект класса DrawningSmallLiner или его наследника
+ /// Поле-объект класса DrawningShip или его наследника
///
- private readonly DrawningSmallLiner? _liner = null;
+ private readonly DrawningShip? _ship = null;
///
/// Конструктор
///
- /// Объект класса DrawningSmallLiner
- public MoveableLiner(DrawningSmallLiner liner)
+ /// Объект класса DrawningShip
+ public MoveableLiner(DrawningShip ship)
{
- _liner = liner;
+ _ship = ship;
}
public ObjectParameters? GetObjectPosition
{
get
{
- if (_liner == null || _liner.EntitySmallLiner == null ||
- !_liner.GetPosX.HasValue || !_liner.GetPosY.HasValue)
+ if (_ship == null || _ship.EntityShip == null ||
+ !_ship.GetPosX.HasValue || !_ship.GetPosY.HasValue)
{
return null;
}
- return new ObjectParameters(_liner.GetPosX.Value,
- _liner.GetPosY.Value, _liner.GetWidth, _liner.GetHeight);
+ return new ObjectParameters(_ship.GetPosX.Value, _ship.GetPosY.Value,
+ _ship.GetWidth, _ship.GetHeight);
}
}
- public int GetStep => (int)(_liner?.EntitySmallLiner?.Step ?? 0);
+ public int GetStep => (int)(_ship?.EntityShip?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
- if (_liner == null || _liner.EntitySmallLiner == null)
+ if (_ship == null || _ship.EntityShip == null)
{
return false;
}
- return _liner.MoveTransport(GetDirectionType(direction));
+ return _ship.MoveTransport(GetDirectionType(direction));
}
///
@@ -62,18 +62,4 @@ public class MoveableLiner : IMoveableObject
_ => DirectionType.Unknow,
};
}
-
- /*public MoveableLiner(DrawningSmallLiner drawningSmallLiner)
- {
- _drawningSmallLiner = drawningSmallLiner;
- }
-
- public ObjectParameters? GetObjectPosition => throw new NotImplementedException();
-
- public int GetStep => throw new NotImplementedException();
-
- public bool TryMoveObject(MovementDirection direction)
- {
- throw new NotImplementedException();
- }*/
}
\ No newline at end of file