From d9e184ca89949115b490269e22e98e5c4875a806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Mon, 26 Sep 2022 17:35:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=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 --- SelfPropelledArtilleryUnit/DrawingArtillery.cs | 5 ++--- SelfPropelledArtilleryUnit/EntityArtillery.cs | 2 +- SelfPropelledArtilleryUnit/FormArtillery.cs | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/SelfPropelledArtilleryUnit/DrawingArtillery.cs b/SelfPropelledArtilleryUnit/DrawingArtillery.cs index bc793c4..38abc72 100644 --- a/SelfPropelledArtilleryUnit/DrawingArtillery.cs +++ b/SelfPropelledArtilleryUnit/DrawingArtillery.cs @@ -15,10 +15,9 @@ namespace Artilleries private int? _pictureHeight = null; private readonly int _artilleryWidth = 80; private readonly int _artilleryHeight = 50; - public void Init(int speed, float weight, Color bodyColor) + public DrawingArtillery(int speed, float weight, Color bodyColor) { - Artillery = new EntityArtillery(); - Artillery.Init(speed, weight, bodyColor); + Artillery = new EntityArtillery(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) { diff --git a/SelfPropelledArtilleryUnit/EntityArtillery.cs b/SelfPropelledArtilleryUnit/EntityArtillery.cs index d3254ca..df6fbf5 100644 --- a/SelfPropelledArtilleryUnit/EntityArtillery.cs +++ b/SelfPropelledArtilleryUnit/EntityArtillery.cs @@ -12,7 +12,7 @@ namespace Artilleries public float Weight { get; private set; } public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodyColor) + public EntityArtillery(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/SelfPropelledArtilleryUnit/FormArtillery.cs b/SelfPropelledArtilleryUnit/FormArtillery.cs index 718c34a..6d8038b 100644 --- a/SelfPropelledArtilleryUnit/FormArtillery.cs +++ b/SelfPropelledArtilleryUnit/FormArtillery.cs @@ -20,9 +20,8 @@ namespace Artilleries private void buttonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _artillery = new DrawingArtillery(); - _artillery.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _artillery.SetPosition(rnd.Next(pictureBoxArtilleries.Width - 161, pictureBoxArtilleries.Width - 81), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height); + _artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height); SpeedStatusLabel.Text = $"Скорость: {_artillery.Artillery.Speed}"; WeightStatusLabel.Text = $"Вес: {_artillery.Artillery.Weight}"; ColorStatusLabel.Text = $"Цвет: {_artillery.Artillery.BodyColor.Name}";