From 2ac8378669ebb61de0d391af57f8e490273efba9 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Tue, 27 Sep 2022 13:03:07 +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 --- Liner/Liner/DrawingShip.cs | 5 ++--- Liner/Liner/EntityShip.cs | 2 +- Liner/Liner/FormShip.cs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Liner/Liner/DrawingShip.cs b/Liner/Liner/DrawingShip.cs index 36c8ff3..2ce7dc1 100644 --- a/Liner/Liner/DrawingShip.cs +++ b/Liner/Liner/DrawingShip.cs @@ -15,10 +15,9 @@ namespace Liner private int? _pictureHeight = null; protected readonly int _ShipWidth = 120; protected readonly int _ShipHeight = 40; - public void Init(int speed, float weight, Color bodycolor) + public DrawingShip(int speed, float weight, Color bodycolor) { - Ship = new EntityShip(); - Ship.Init(speed, weight, bodycolor); + Ship = new EntityShip(speed, weight, bodycolor); } public void SetPosition(int x, int y, int width, int height) diff --git a/Liner/Liner/EntityShip.cs b/Liner/Liner/EntityShip.cs index 46613d6..7946fa5 100644 --- a/Liner/Liner/EntityShip.cs +++ b/Liner/Liner/EntityShip.cs @@ -16,7 +16,7 @@ namespace Liner public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodycolor) + public EntityShip(int speed, float weight, Color bodycolor) { Speed = speed; Weight = weight; diff --git a/Liner/Liner/FormShip.cs b/Liner/Liner/FormShip.cs index 4eb0604..68223cf 100644 --- a/Liner/Liner/FormShip.cs +++ b/Liner/Liner/FormShip.cs @@ -23,8 +23,7 @@ namespace Liner private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _ship = new DrawingShip(); - _ship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _ship = new DrawingShip(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}";