Переход на конструктор
This commit is contained in:
parent
6d79ecf407
commit
34bacd6d35
@ -32,7 +32,7 @@ namespace WinFormsApp1
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
@ -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}";
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
//Установка позиции сущности
|
||||
|
Loading…
Reference in New Issue
Block a user