diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs index c51638b..58e332d 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs @@ -45,10 +45,9 @@ namespace DoubleDeckerBus /// Скорость /// Вес автобуса /// Цвет кузова - public void Init(int speed, float weight, Color bodyColor) + public DrawningBus(int speed, float weight, Color bodyColor) { - Bus = new EntityBus(); - Bus.Init(speed, weight, bodyColor); + Bus = new EntityBus(speed, weight, bodyColor); } /// /// Установка позиции автобуса diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs index e04fa53..74ace8c 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs @@ -34,7 +34,7 @@ namespace DoubleDeckerBus /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityBus(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs index 90c0c0e..11caede 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs @@ -24,8 +24,7 @@ namespace DoubleDeckerBus private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _bus = new DrawningBus(); - _bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), + _bus = new DrawningBus(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);