Переход на конструкторы.

This commit is contained in:
Anastasia 2022-10-03 20:14:22 +04:00
parent 0832085f20
commit ae14815155
3 changed files with 4 additions and 6 deletions

View File

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

View File

@ -35,7 +35,7 @@ namespace AirplaneWithRadar
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
public EntityAirplane(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;

View File

@ -27,8 +27,7 @@ namespace AirplaneWithRadar
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_airplane = new DrawingAirplane();
_airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
_airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
pictureBoxAirplane.Width, pictureBoxAirplane.Height);