Переход на конструкторы.
This commit is contained in:
parent
16169bc878
commit
7b553ddbb5
@ -24,10 +24,9 @@ namespace Airbus
|
||||
protected readonly int _airbusHeight = 16; //высота отрисовки самолёта
|
||||
|
||||
//инициализаци свойств
|
||||
public void Initial(int speed, float weight, Color corpusColor)
|
||||
public DrawingAirbus(int speed, float weight, Color corpusColor)
|
||||
{
|
||||
Airbus = new EntityAirbus();
|
||||
Airbus.Initial(speed, weight, corpusColor);
|
||||
Airbus = new EntityAirbus(speed, weight, corpusColor);
|
||||
}
|
||||
|
||||
//установка координат позиции самолёта
|
||||
|
@ -16,7 +16,7 @@ namespace Airbus
|
||||
|
||||
public float Step => Speed * 100 / Weight; //шаг перемещения самолёта
|
||||
|
||||
public void Initial(int speed, float weight, Color corpusColor)
|
||||
public EntityAirbus(int speed, float weight, Color corpusColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
|
@ -32,8 +32,7 @@ namespace Airbus
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_airbus = new DrawingAirbus();
|
||||
_airbus.Initial(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_airbus = new DrawingAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_airbus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirbus.Width, pictureBoxAirbus.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_airbus.Airbus?.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {_airbus.Airbus?.Weight}";
|
||||
|
Loading…
Reference in New Issue
Block a user