From 1c30871417de9791b3b94571b81d055ad1c8e0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Mon, 28 Nov 2022 23:26:56 +0400 Subject: [PATCH] rework construction --- DrawingShip.java | 5 ++--- EntityWarmlyShip.java | 2 +- FormShip.java | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) 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() + " ");