From 746f60a4b1fde36e03d70084a3e40f8d280b093e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 4 Oct 2022 16:41:33 +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 --- AirBomber/AirBomber/DrawningBomber.cs | 5 ++--- AirBomber/AirBomber/EntityAirBomber.cs | 4 ++-- AirBomber/AirBomber/FormAirBomber.cs | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) 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}";