From 5669b4e535c1d558541e54e8144c49fe47c88244 Mon Sep 17 00:00:00 2001 From: Sem730 Date: Mon, 26 Sep 2022 22:25:23 +0300 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 --- ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs | 5 ++--- ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs | 2 +- ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs index 0aa3f7a..fd3163e 100644 --- a/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/DrawningLocomotive.cs @@ -45,10 +45,9 @@ namespace ProjectLocomotive /// Скорость /// Вес локомотива /// Цвет кузова - public void Init(int speed, float weight, Color bodyColor) + public DrawningLocomotive(int speed, float weight, Color bodyColor) { - Locomotivе = new EntityLocomotive(); - Locomotivе.Init(speed, weight, bodyColor); + Locomotivе = new EntityLocomotive(speed, weight, bodyColor); } /// /// Установка позиции автомобиля diff --git a/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs index 7ff411d..1f7dfe1 100644 --- a/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/EntityLocomotive.cs @@ -31,7 +31,7 @@ namespace ProjectLocomotive /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityLocomotive(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs index 5827c25..c082a4f 100644 --- a/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs +++ b/ProjectLocomotive/ProjectLocomotive/FormLocomotive.cs @@ -28,8 +28,7 @@ namespace ProjectLocomotive private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _elloc = new DrawningLocomotive(); - _elloc.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _elloc = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _elloc.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); toolStripStatusLabelSpeed.Text = $": {_elloc.Locomotiv.Speed}"; toolStripStatusLabelWeight.Text = $": {_elloc.Locomotiv.Weight}";