From 34bacd6d359b8b7f6f23ef401b1c8985cc2ec16a Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 13 Nov 2022 21:10:48 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormsApp1/EntityTractor.cs | 2 +- WinFormsApp1/FormTractor.cs | 3 +-- WinFormsApp1/TractorDraw.cs | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/WinFormsApp1/EntityTractor.cs b/WinFormsApp1/EntityTractor.cs index dcb191f..088ce6a 100644 --- a/WinFormsApp1/EntityTractor.cs +++ b/WinFormsApp1/EntityTractor.cs @@ -32,7 +32,7 @@ namespace WinFormsApp1 /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityTractor(int speed, float weight, Color bodyColor) { Random rnd = new Random(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/WinFormsApp1/FormTractor.cs b/WinFormsApp1/FormTractor.cs index 7e4ca4b..16e9570 100644 --- a/WinFormsApp1/FormTractor.cs +++ b/WinFormsApp1/FormTractor.cs @@ -31,8 +31,7 @@ namespace WinFormsApp1 private void ButtonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - _Tractor = new TractorDraw(); - _Tractor.Init(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + _Tractor = new TractorDraw(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); _Tractor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTractor.Width, pictureBoxTractor.Height); toolStripStatusLabelSpeed.Text = $"Скорость: {_Tractor.Tractor.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_Tractor.Tractor.Weight}"; diff --git a/WinFormsApp1/TractorDraw.cs b/WinFormsApp1/TractorDraw.cs index 41341d8..f94101e 100644 --- a/WinFormsApp1/TractorDraw.cs +++ b/WinFormsApp1/TractorDraw.cs @@ -25,10 +25,9 @@ namespace WinFormsApp1 /// Высота отрисовки сущности private readonly int entHeight = 100; - public void Init(int speed, float weight, Color bodycolor) + public TractorDraw(int speed, float weight, Color bodycolor) { - Tractor = new EntityTractor(); - Tractor.Init(speed, weight, bodycolor); + Tractor = new EntityTractor(speed, weight, bodycolor); } //Установка позиции сущности