Init -> конструкторы

This commit is contained in:
Владислав Захаров 2022-09-26 20:00:28 +04:00
parent 471ece01d3
commit 2737314d41
3 changed files with 4 additions and 6 deletions

View File

@ -22,8 +22,7 @@ namespace Traktor
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_Traktor = new TraktorDraw();
_Traktor.Init(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
_Traktor = new TraktorDraw(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
_Traktor.SetPosition(random.Next(10, 50), random.Next(10, 50), pictureBoxTraktor.Width, pictureBoxTraktor.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_Traktor.Traktor.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_Traktor.Traktor.Weight}";

View File

@ -20,7 +20,7 @@ namespace Traktor
//Шаг перемещения трактора
public float Step => Speed * 100 / Weight;
public void Init(int speed, float weight, Color bodycolor)
public EntityTraktor(int speed, float weight, Color bodycolor)
{
Random rnd = new Random();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;

View File

@ -26,10 +26,9 @@ namespace Traktor
/// Высота отрисовки сущности
private readonly int entHeight = 100;
public void Init(int speed, float weight, Color bodycolor)
public TraktorDraw(int speed, float weight, Color bodycolor)
{
Traktor = new EntityTraktor();
Traktor.Init(speed, weight, bodycolor);
Traktor = new EntityTraktor(speed, weight, bodycolor);
}
//Установка позиции сущности