diff --git a/AirBomber/AirBomber/DrawningBomber.cs b/AirBomber/AirBomber/DrawningBomber.cs index 6b37f11..91422e1 100644 --- a/AirBomber/AirBomber/DrawningBomber.cs +++ b/AirBomber/AirBomber/DrawningBomber.cs @@ -16,10 +16,9 @@ namespace AirBomber private readonly int _airBomberWidth = 100; private readonly int _airBomberHeight = 100; - public void Init(int speed, float weight, Color bodyColor) + public DrawningBomber(int speed, float weight, Color bodyColor) { - AirBomber = new EntityAirBomber(); - AirBomber.Init(speed, weight, bodyColor); + AirBomber = new EntityAirBomber(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index 86c87af..8c5f25d 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -13,9 +13,9 @@ namespace AirBomber public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodyColor) + public EntityAirBomber(int speed, float weight, Color bodyColor) { - Random rnd = new(); + Random rnd = new Random(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; Weight = weight <= 0 ? rnd.Next(40, 70) : weight; BodyColor = bodyColor; diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index f521ff7..f2b0106 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -19,8 +19,7 @@ namespace AirBomber private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _airBomber = new DrawningBomber(); - _airBomber.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _airBomber = new DrawningBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _airBomber.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); toolStripStatusLabelSpeed.Text = $"Скорость: {_airBomber.AirBomber.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_airBomber.AirBomber.Weight}";