DozorovaA.A_SecondLabWork #2
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
/// Установка позиции
|
||||
|
@ -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}";
|
||||
|
Loading…
Reference in New Issue
Block a user