diff --git a/DrawingShip.java b/DrawingShip.java index 24462b0..f504d6e 100644 --- a/DrawingShip.java +++ b/DrawingShip.java @@ -16,10 +16,9 @@ public class DrawingShip extends JPanel { private DrawDeck dd = new DrawDeck(); //Инициализация - public void Init(int speed, float weight, Color bodyColor) + public DrawingShip(int speed, float weight, Color bodyColor) { - warmlyShip = new EntityWarmlyShip(); - warmlyShip.Init(speed, weight, bodyColor); + warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor); Random random = new Random(); dd.SetDeckCount(random.nextInt(1, 4)); } diff --git a/EntityWarmlyShip.java b/EntityWarmlyShip.java index 81136c8..073ec41 100644 --- a/EntityWarmlyShip.java +++ b/EntityWarmlyShip.java @@ -8,7 +8,7 @@ public class EntityWarmlyShip { private float Step; //Шаг при перемещении //Инициализация - public void Init(int speed, float weight, Color bodyColor) + public EntityWarmlyShip(int speed, float weight, Color bodyColor) { Random random = new Random(); Speed = speed <= 0 ? random.nextInt(50, 150) : speed; diff --git a/FormShip.java b/FormShip.java index 2548441..7fa214a 100644 --- a/FormShip.java +++ b/FormShip.java @@ -83,8 +83,7 @@ public class FormShip extends JFrame{ @Override public void actionPerformed(ActionEvent e) { Random random = new Random(); - ship = new DrawingShip(); - ship.Init(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256))); + ship = new DrawingShip(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256))); ship.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), GraphicsOutput.getWidth(), GraphicsOutput.getHeight()); JLabelSpeed.setText("Cкорость: " + ship.GetWarmlyShip().GetSpeed() + " "); JLabelWeight.setText("Вес: " + ship.GetWarmlyShip().GetWeight() + " ");