Переход на конструкторы
This commit is contained in:
parent
747b5c1c87
commit
f9ff52e57b
@ -45,10 +45,9 @@ namespace WarmlyLocomotive
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес локомотива</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции локомотива
|
||||
|
@ -31,7 +31,7 @@ namespace WarmlyLocomotive
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
@ -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}";
|
||||
|
Loading…
Reference in New Issue
Block a user