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