From f6797078a89f7045f12fffe9a7d9cd6255507190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sun, 9 Oct 2022 17:36:10 +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 --- Bus/Bus/DrawingBus.cs | 5 ++--- Bus/Bus/EntityBus.cs | 2 +- Bus/Bus/FormBus.cs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Bus/Bus/DrawingBus.cs b/Bus/Bus/DrawingBus.cs index 958cb34..00a4a2c 100644 --- a/Bus/Bus/DrawingBus.cs +++ b/Bus/Bus/DrawingBus.cs @@ -16,10 +16,9 @@ namespace Bus protected readonly int _busWidth = 157; protected readonly int _busHeight = 65; - public void Init(int speed, float weight, Color bodyColor) + public DrawingBus(int speed, float weight, Color bodyColor) { - Bus = new EntityBus(); - Bus.Init(speed, weight, bodyColor); + Bus = new EntityBus(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) diff --git a/Bus/Bus/EntityBus.cs b/Bus/Bus/EntityBus.cs index c479713..d69a43a 100644 --- a/Bus/Bus/EntityBus.cs +++ b/Bus/Bus/EntityBus.cs @@ -13,7 +13,7 @@ namespace Bus public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init (int speed, float weight, Color bodyColor) + public EntityBus (int speed, float weight, Color bodyColor) { Random rnd = new Random(); Speed = speed <=0 ? rnd.Next(50,150) : speed; diff --git a/Bus/Bus/FormBus.cs b/Bus/Bus/FormBus.cs index 5cd241b..49fa996 100644 --- a/Bus/Bus/FormBus.cs +++ b/Bus/Bus/FormBus.cs @@ -21,8 +21,7 @@ namespace Bus private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _bus = new DrawingBus(); - _bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _bus.SetPosition(rnd.Next(10,100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height); toolStripStatusLabelSpeed.Text = $"Скорость: {_bus.Bus?.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_bus.Bus?.Weight}";