diff --git a/DrawningBomber.java b/DrawningBomber.java index 395a0aa..cb6fcfe 100644 --- a/DrawningBomber.java +++ b/DrawningBomber.java @@ -5,6 +5,7 @@ import java.util.*; public class DrawningBomber extends JPanel { private EntityAirBomber AirBomber; + public EntityAirBomber getAirBomber() { return AirBomber; } private float _startPosX; private float _startPosY; @@ -16,10 +17,9 @@ public class DrawningBomber extends JPanel private int NumEngines = 1; private DrawEngines drawEngines = new DrawEngines(); - public void Init(int speed, float weight, Color bodyColor) + public DrawningBomber(int speed, float weight, Color bodyColor) { - AirBomber = new EntityAirBomber(); - AirBomber.Init(speed, weight, bodyColor); + AirBomber = new EntityAirBomber(speed, weight, bodyColor); Random random = new Random(); drawEngines.SetNumEngines(random.nextInt(1, 4)); } diff --git a/EntityAirBomber.java b/EntityAirBomber.java index 235946a..5c279c4 100644 --- a/EntityAirBomber.java +++ b/EntityAirBomber.java @@ -8,7 +8,7 @@ public class EntityAirBomber private Color BodyColor; private float Step; - public void Init(int speed, float weight, Color bodyColor) + public EntityAirBomber(int speed, float weight, Color bodyColor) { Random rnd = new Random(); Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed; diff --git a/FormAirBomber.java b/FormAirBomber.java index 9db376d..6fe0b6b 100644 --- a/FormAirBomber.java +++ b/FormAirBomber.java @@ -71,7 +71,7 @@ public class FormAirBomber { @Override public void actionPerformed(ActionEvent e) { Random random = new Random(); - pictureBomber.Init(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256))); + pictureBomber = new DrawningBomber(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256))); pictureBomber.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), pictureBomber.getWidth(), pictureBomber.getHeight()); JLabelSpeed.setText("Cкорость: " + pictureBomber.getAirBomber().GetSpeed() + " "); JLabelWeight.setText("Вес: " + pictureBomber.getAirBomber().GetWeight() + " ");