Malin D.V. Lab work 2 #2

Merged
eegov merged 7 commits from LabWork_02 into LabWork_01 2022-10-07 08:52:07 +04:00
3 changed files with 4 additions and 6 deletions
Showing only changes of commit f9ff52e57b - Show all commits

View File

@ -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>
/// Установка позиции локомотива

View File

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

View File

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