Krasnikov D.D Lab work 2 #2

Closed
L1ontiev wants to merge 2 commits from LABA2 into LABA1
3 changed files with 4 additions and 6 deletions
Showing only changes of commit 34bacd6d35 - Show all commits

View File

@ -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;

View File

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

View File

@ -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);
}
//Установка позиции сущности