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}";