From 1641fc1883cf0f82febde749865735c421fa6636 Mon Sep 17 00:00:00 2001 From: AnnaLioness Date: Fri, 6 Oct 2023 17:29:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B0=D0=B12.=D0=B8=D0=B7=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingContainerShip.cs | 5 +- .../Lab1ContainersShip/DrawingShip.cs | 61 ++----------------- .../Lab1ContainersShip/EntityShip.cs | 4 +- .../Lab1ContainersShip/Form1.cs | 50 +-------------- 4 files changed, 9 insertions(+), 111 deletions(-) diff --git a/Lab1ContainersShip/Lab1ContainersShip/DrawingContainerShip.cs b/Lab1ContainersShip/Lab1ContainersShip/DrawingContainerShip.cs index af1ebf8..bbfee78 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/DrawingContainerShip.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/DrawingContainerShip.cs @@ -22,10 +22,7 @@ additionalColor, bool crane, bool containers, int width, int height) : } public override void DrawShip(Graphics g) { - /*if (EntityShip is not EntityContainerShip containerShip) - { - return; - }*/ + if(EntityShip == null) { return; diff --git a/Lab1ContainersShip/Lab1ContainersShip/DrawingShip.cs b/Lab1ContainersShip/Lab1ContainersShip/DrawingShip.cs index ab668d8..a080e88 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/DrawingShip.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/DrawingShip.cs @@ -10,9 +10,7 @@ namespace Lab1ContainersShip.DrawingObjects { public class DrawingShip { - /// - /// Класс-сущность - /// + public EntityShip EntityShip { get; protected set; } /// /// Ширина окна @@ -72,22 +70,7 @@ namespace Lab1ContainersShip.DrawingObjects } } - /*public bool Init(int speed, double weight, Color bodyColor, Color -additionalColor, bool crane, bool container, int width, int height) - { - // TODO: Продумать проверки - _pictureWidth = width; - _pictureHeight = height; - if (_pictureWidth < _shipWidth || _pictureHeight < _shipHeight) - { - return false; - } - EntityShip = new EntityShip(); - EntityShip.Init(speed, weight, bodyColor, additionalColor, - crane, container); - - return true; - }*/ + public DrawingShip(int speed, double weight, Color bodyColor, int width, int height) { if(width < _shipWidth || height < _shipHeight) @@ -110,18 +93,7 @@ additionalColor, bool crane, bool container, int width, int height) _shipWidth = shipWidth; EntityShip = new EntityShip(speed, weight, bodyColor); } - /*public bool Init(EntityContainerShip entcon, int wid, int hei) - { - _pictureWidth = wid; - _pictureHeight = hei; - if (_pictureWidth < _shipWidth || _pictureHeight < _shipHeight) - { - return false; - } - EntityContainerShip = entcon; - return true; - - }*/ + public void SetPosition(int x, int y) @@ -202,32 +174,7 @@ additionalColor, bool crane, bool container, int width, int height) g.DrawLine(pen, _startPosX + 20, _startPosY + 55, _startPosX + 30, _startPosY + 55); //контейнеры - /*if (EntityShip.Conteiners) - { - g.FillRectangle(adbrush, _startPosX + 30, _startPosY + 35, 35, 10); - g.FillRectangle(adbrush, _startPosX + 65, _startPosY + 35, 20, 10); - g.FillRectangle(adbrush, _startPosX + 85, _startPosY + 30, 15, 15); - g.FillRectangle(adbrush, _startPosX + 30, _startPosY + 25, 15, 10); - g.FillRectangle(adbrush, _startPosX + 45, _startPosY + 25, 55, 5); - g.FillRectangle(adbrush, _startPosX + 45, _startPosY + 30, 40, 5); - - g.DrawRectangle(pen, _startPosX + 30, _startPosY + 35, 35, 10); - g.DrawRectangle(pen, _startPosX + 65, _startPosY + 35, 20, 10); - g.DrawRectangle(pen, _startPosX + 85, _startPosY + 30, 15, 15); - g.DrawRectangle(pen, _startPosX + 30, _startPosY + 25, 15, 10); - g.DrawRectangle(pen, _startPosX + 45, _startPosY + 25, 55, 5); - g.DrawRectangle(pen, _startPosX + 45, _startPosY + 30, 40, 5); - } - //кран - if (EntityShip.Crane) - { - g.FillRectangle(adbrush, _startPosX + 23, _startPosY, 5, 45); - g.FillRectangle(adbrush, _startPosX + 27, _startPosY + 10, 20, 3); - g.DrawRectangle(pen, _startPosX + 23, _startPosY, 5, 45); - g.DrawRectangle(pen, _startPosX + 27, _startPosY + 10, 20, 3); - g.DrawLine(pen, _startPosX + 27, _startPosY, _startPosX + 47, _startPosY + 10); - g.DrawLine(pen, _startPosX + 47, _startPosY + 13, _startPosX + 47, _startPosY + 25); - }*/ + } } } diff --git a/Lab1ContainersShip/Lab1ContainersShip/EntityShip.cs b/Lab1ContainersShip/Lab1ContainersShip/EntityShip.cs index cd16399..c3cc52e 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/EntityShip.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/EntityShip.cs @@ -41,9 +41,7 @@ namespace Lab1ContainersShip.Entities Speed = speed; Weight = weight; BodyColor = bodyColor; - //AdditionalColor = additionalColor; - //Crane = crane; - //Conteiners = containers; + } } } diff --git a/Lab1ContainersShip/Lab1ContainersShip/Form1.cs b/Lab1ContainersShip/Lab1ContainersShip/Form1.cs index 787fb19..184991b 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/Form1.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/Form1.cs @@ -16,9 +16,7 @@ namespace Lab1ContainersShip { private DrawingShip _drawingShip; - /// - /// Стратегия перемещения - /// + private AbstractStrategy _abstractStrategy; @@ -26,17 +24,7 @@ namespace Lab1ContainersShip { InitializeComponent(); } - /// - /// Поле-объект для прорисовки объекта - /// - /// - /// Инициализация формы - /// - - /// - /// Метод прорисовки машины - /// private void Draw() { @@ -59,33 +47,7 @@ namespace Lab1ContainersShip } - /*private void buttonCreate_Click(object sender, EventArgs e) - { - Random random = new Random(); - _drawningShip = new DrawingShip(); - EntityShip _entitycont = new EntityShip();*/ - /*_entitycont.Init(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)), - Convert.ToBoolean(random.Next(0, 2)), - Convert.ToBoolean(random.Next(0, 2)));*/ - /*_drawningShip.Init(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)), - Convert.ToBoolean(random.Next(0, 2)), - Convert.ToBoolean(random.Next(0, 2)), - pictureBox1.Width, pictureBox1.Height); - //_drawningShip.Init(_entitycont, pictureBox1.Width, pictureBox1.Height); - _drawningShip.SetPosition(random.Next(10, 100), - random.Next(10, 100)); - Draw(); - }*/ + private void buttonMove_Click(object sender, EventArgs e) { if (_drawingShip == null) @@ -119,13 +81,7 @@ namespace Lab1ContainersShip } if (comboBoxStrategy.Enabled) { - /*_abstractStrategy = comboBoxStrategy.SelectedIndex - switch - { - 0 => new MoveToCenter(), - 1 => new MoveToBorder(), - _ => null, - };*/ + switch (comboBoxStrategy.SelectedIndex) { case 0: