переход к конструкторам

This commit is contained in:
devil_1nc 2022-09-26 20:36:53 +04:00
parent ce9a95178c
commit 4f76d25f8d
3 changed files with 4 additions and 6 deletions

View File

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

View File

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

View File

@ -48,8 +48,7 @@
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rand = new Random();
_plane = new DrawingPlane();
_plane.Init(rand.Next(200, 500), rand.Next(2000, 3000),
_plane = new DrawingPlane(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);