From 30470e240f733f6786ae6c9de95dd2f96bda68b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 13 Dec 2022 20:24:12 +0400 Subject: [PATCH] lab2 first steps --- DrawningBomber.java | 6 +++--- EntityAirBomber.java | 2 +- FormAirBomber.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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() + " ");