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); } //Установка позиции сущности