From d35b31c29c567e3c2177a2e2835ab3d6db1c425e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 21 Sep 2022 10:11:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 5 ++--- WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 2 +- WarmlyShip/WarmlyShip/FormClass.cs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b131644..ac2bdeb 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -16,10 +16,9 @@ namespace WarmlyShip private readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля - public void Init(int speed, float weight, Color bodyColor) + public DrawingWarmlyShip(int speed, float weight, Color bodyColor) { - warmlyShip = new EntityWarmlyShip(); - warmlyShip.Init(speed, weight, bodyColor); + warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 29576fb..0049f81 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -13,7 +13,7 @@ namespace WarmlyShip public Color BodyColor { get; private set; } //Цвет public float Step => Speed * 100 / Weight; //Шаг при перемещении - public void Init(int speed, float weight, Color bodyColor) + public EntityWarmlyShip(int speed, float weight, Color bodyColor) { Random random = new Random(); Speed = speed <= 0 ? random.Next(50, 150) : speed; diff --git a/WarmlyShip/WarmlyShip/FormClass.cs b/WarmlyShip/WarmlyShip/FormClass.cs index 23e86ce..02796ed 100644 --- a/WarmlyShip/WarmlyShip/FormClass.cs +++ b/WarmlyShip/WarmlyShip/FormClass.cs @@ -20,8 +20,7 @@ namespace WarmlyShip private void ButtonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - _warmlyShip = new DrawingWarmlyShip(); - _warmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + _warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); _warmlyShip.SetPosition(random.Next(pictureBox.Width - 150, pictureBox.Width - 125), random.Next(pictureBox.Height - 150, pictureBox.Height - 50), pictureBox.Width, pictureBox.Height); toolStripStatusSpeed.Text = $": {_warmlyShip.warmlyShip?.Speed}"; toolStripStatusWeight.Text = $": {_warmlyShip.warmlyShip?.Weight}";