Переход на конструкторы.
This commit is contained in:
parent
0832085f20
commit
ae14815155
@ -45,10 +45,9 @@ namespace AirplaneWithRadar
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес самолета</param>
|
/// <param name="weight">Вес самолета</param>
|
||||||
/// <param name="bodyColor">Цвет кузова</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 = new EntityAirplane(speed, weight, bodyColor);
|
||||||
Airplane.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции самолета
|
/// Установка позиции самолета
|
||||||
|
@ -35,7 +35,7 @@ namespace AirplaneWithRadar
|
|||||||
/// <param name="weight"></param>
|
/// <param name="weight"></param>
|
||||||
/// <param name="bodyColor"></param>
|
/// <param name="bodyColor"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityAirplane(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
@ -27,8 +27,7 @@ namespace AirplaneWithRadar
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airplane = new DrawingAirplane();
|
_airplane = new DrawingAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
_airplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
_airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
pictureBoxAirplane.Width, pictureBoxAirplane.Height);
|
pictureBoxAirplane.Width, pictureBoxAirplane.Height);
|
||||||
|
Loading…
Reference in New Issue
Block a user