lab2 first steps

This commit is contained in:
Артём Алейкин 2022-12-13 20:24:12 +04:00
parent 3166c0b054
commit 30470e240f
3 changed files with 5 additions and 5 deletions

View File

@ -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));
}

View File

@ -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;

View File

@ -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("орость: " + pictureBomber.getAirBomber().GetSpeed() + " ");
JLabelWeight.setText("Вес: " + pictureBomber.getAirBomber().GetWeight() + " ");