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