Переход на конструкторы
This commit is contained in:
parent
62e0ec9148
commit
001cdd770b
@ -45,10 +45,9 @@ namespace AntiAircraftGun
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес зенитного орудия</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawingAntiAircraftGun(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
AntiAircraftGun = new EntityAntiAircraftGun();
|
||||
AntiAircraftGun.Init(speed, weight, bodyColor);
|
||||
AntiAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции зенитного орудия
|
||||
|
@ -31,7 +31,7 @@ namespace AntiAircraftGun
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityAntiAircraftGun(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
@ -32,8 +32,7 @@ namespace AntiAircraftGun
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_antiAircrafGun = new DrawingAntiAircraftGun();
|
||||
_antiAircrafGun.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
_antiAircrafGun = new DrawingAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_antiAircrafGun.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||
|
Loading…
Reference in New Issue
Block a user