DozorovaA.A_SecondLabWork #2

Merged
eegov merged 8 commits from SecondLabWork into FirstLabWork 2022-09-30 11:05:38 +04:00
3 changed files with 13 additions and 12 deletions
Showing only changes of commit e81bd3dfa7 - Show all commits

View File

@ -8,6 +8,14 @@ namespace ArmoredVehicle
{
internal class ArmoredVehicleEntity
{
public ArmoredVehicleEntity(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
/// <summary>
/// Скорость
/// </summary>
@ -31,12 +39,6 @@ namespace ArmoredVehicle
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
}
}

View File

@ -42,10 +42,9 @@ namespace ArmoredVehicle
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес </param>
/// <param name="bodyColor">Цвет</param>
public void Init(int speed, float weight, Color bodyColor)
public DrawingArmoredVehicle(int speed, float weight, Color bodyColor)
{
ArmoredVehicle = new ArmoredVehicleEntity();
ArmoredVehicle.Init(speed, weight, bodyColor);
ArmoredVehicle = new ArmoredVehicleEntity(speed, weight, bodyColor);
}
/// <summary>
/// Установка позиции

View File

@ -34,8 +34,8 @@ namespace ArmoredVehicle
private void CreateButton_Click(object sender, EventArgs e)
{
Random rnd = new();
_ArmoredVehicle = new DrawingArmoredVehicle();
_ArmoredVehicle.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_ArmoredVehicle = new DrawingArmoredVehicle(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_ArmoredVehicle.SetPosition(/*rnd.Next(0, 100)*/ -10, rnd.Next(0, 100), DrawingPictureBox.Width, DrawingPictureBox.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_ArmoredVehicle.ArmoredVehicle.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_ArmoredVehicle.ArmoredVehicle.Weight}";