diff --git a/.idea/misc.xml b/.idea/misc.xml index 018dc79..344243f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/DrawingWarship.java b/src/DrawingWarship.java index 04c5463..f7aacff 100644 --- a/src/DrawingWarship.java +++ b/src/DrawingWarship.java @@ -14,10 +14,9 @@ public class DrawingWarship { private final int _warshipWidth = 114; private final int _warshipHeight = 40; - public void Init(int speed, float weight, Color bodyColor) + public DrawingWarship(int speed, float weight, Color bodyColor) { - Warship = new EntityWarship(); - Warship.Init(speed, weight, bodyColor); + Warship = new EntityWarship(speed, weight, bodyColor); Blocks = new DrawingBlocks(); Blocks.blockDirection = BlockRandom(); } diff --git a/src/EntityWarship.java b/src/EntityWarship.java index 092a65b..fd0d84d 100644 --- a/src/EntityWarship.java +++ b/src/EntityWarship.java @@ -11,11 +11,11 @@ public class EntityWarship { public Color GetBodyColor (){return BodyColor;} public float Step; - public void Init(int speed, float weight, Color bodyColor) + public EntityWarship(int speed, float weight, Color bodyColor) { Random rnd = new Random(); - Speed = speed <= 0 ? rnd.nextInt(100) + 50 : speed; - Weight = weight <= 0 ? rnd.nextInt(30)+40 : weight; + Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed; + Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight; BodyColor= bodyColor; Step = Speed * 100 / Weight; } diff --git a/src/FormWarship.java b/src/FormWarship.java index 404303a..020ae3a 100644 --- a/src/FormWarship.java +++ b/src/FormWarship.java @@ -50,8 +50,7 @@ public class FormWarship extends JFrame { @Override public void actionPerformed(ActionEvent e) { Random rnd = new Random(); - _warship = new DrawingWarship(); - _warship.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + _warship = new DrawingWarship(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256))); _warship.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight()); toolBarLabelSpeed.setText("Color: " + _warship.GetWarship().GetSpeed() + " ");