Переход на конструкторы
This commit is contained in:
parent
6eb0ae0dc9
commit
91d21e3081
@ -45,10 +45,9 @@ namespace AirFighter
|
|||||||
/// <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 DrawningAirFighter(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
AirFighter = new EntityAirFighter();
|
AirFighter = new EntityAirFighter(speed, weight, bodyColor);
|
||||||
AirFighter.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции самолета
|
/// Установка позиции самолета
|
||||||
|
@ -34,7 +34,7 @@ namespace AirFighter
|
|||||||
/// <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 EntityAirFighter(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;
|
||||||
|
@ -24,9 +24,8 @@ namespace AirFighter
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_airFighter = new DrawningAirFighter();
|
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
_airFighter.Init(rnd.Next(200, 500), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airFighter.AirFighter?.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airFighter.AirFighter?.Speed}";
|
||||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_airFighter.AirFighter?.Weight}";
|
toolStripStatusLabelWeight.Text = $"Âåñ: {_airFighter.AirFighter?.Weight}";
|
||||||
|
Loading…
Reference in New Issue
Block a user