From f9ff52e57b2e1d42d8b69c08b07d5a983db495f1 Mon Sep 17 00:00:00 2001 From: Danil Malin Date: Fri, 23 Sep 2022 18:29:37 +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=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs | 5 ++--- WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs | 2 +- WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs index 24aeb64..7ffcbe6 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/DrawningLocomotive.cs @@ -45,10 +45,9 @@ namespace WarmlyLocomotive /// Скорость /// Вес локомотива /// Цвет кузова - public void Init(int speed, float weight, Color bodyColor) + public DrawningLocomotive(int speed, float weight, Color bodyColor) { - Locomotive = new EntityLocomotive(); - Locomotive.Init(speed, weight, bodyColor); + Locomotive = new EntityLocomotive(speed, weight, bodyColor); } /// /// Установка позиции локомотива diff --git a/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs index bbd2bd4..36ee67c 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/EntityLocomotive.cs @@ -31,7 +31,7 @@ namespace WarmlyLocomotive /// /// /// - 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/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs index b7fd364..9e6d19f 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/FormLocomotive.cs @@ -25,8 +25,7 @@ namespace WarmlyLocomotive private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _locomotive = new DrawningLocomotive(); - _locomotive.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height); toolStripStatusLabelSpeed.Text = $": {_locomotive.Locomotive.Speed}"; toolStripStatusLabelWeight.Text = $": {_locomotive.Locomotive.Weight}";