Лаборатная работа 1

This commit is contained in:
devil_1nc 2022-09-26 20:32:29 +04:00
parent e936b4d813
commit b66671fd10
3 changed files with 6 additions and 4 deletions

View File

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

View File

@ -32,7 +32,7 @@ namespace ProjectPlane
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public EntityPlane(int speed, float weight, Color bodyColor)
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(350, 550) : speed;

View File

@ -48,7 +48,8 @@
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rand = new Random();
_plane = new DrawingPlane(rand.Next(200, 500), rand.Next(2000, 3000),
_plane = new DrawingPlane();
_plane.Init(rand.Next(200, 500), rand.Next(2000, 3000),
Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)));
_plane.SetPosition(rand.Next(5, 100), rand.Next(40, 100),
pictureBoxPlane.Width, pictureBoxPlane.Height);