From 2a1c4990961d42a5425a45f41d15385af78161d8 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Mon, 21 Nov 2022 23:55:09 +0400 Subject: [PATCH] finally --- DrawingPlane.java => DrawingAirbus.java | 50 ++++++++++++------------- EntityPlane.java => EntityAirbus.java | 2 +- FormPlane.java => FormAirbus.java | 20 +++++----- 3 files changed, 36 insertions(+), 36 deletions(-) rename DrawingPlane.java => DrawingAirbus.java (79%) rename EntityPlane.java => EntityAirbus.java (96%) rename FormPlane.java => FormAirbus.java (84%) diff --git a/DrawingPlane.java b/DrawingAirbus.java similarity index 79% rename from DrawingPlane.java rename to DrawingAirbus.java index 28fbb15..c162d1a 100644 --- a/DrawingPlane.java +++ b/DrawingAirbus.java @@ -1,29 +1,29 @@ import java.awt.*; -public class DrawingPlane { - public EntityPlane Plane; +public class DrawingAirbus { + public EntityAirbus Airbus; private float _startPosX; private float _startPosY; private Integer _pictureWidth = null; private Integer _pictureHeight = null; - private final int _planeWidth = 125; - private final int _planeHeight = 45; + private final int _airbusWidth = 125; + private final int _airbusHeight = 45; public DrawingIlum drawingilum; - public void Init(int speed, float weight, Color bodyColor, int ilNum, EntityPlane entity) + public void Init(int speed, float weight, Color bodyColor, int ilNum, EntityAirbus entity) { - Plane = entity; + Airbus = entity; drawingilum = new DrawingIlum(); drawingilum.Init(ilNum, bodyColor); - Plane.Init(speed, weight, bodyColor); + Airbus.Init(speed, weight, bodyColor); } public void SetPosition(int x, int y, int width, int height) { - if (x < 0 || x + _planeWidth >= width) + if (x < 0 || x + _airbusWidth >= width) { return; } - if (y < 0 || y + _planeHeight >= height) + if (y < 0 || y + _airbusHeight >= height) { return; } @@ -42,36 +42,36 @@ public class DrawingPlane { { // вправо case Right: - if (_startPosX + _planeWidth + Plane.Step() < _pictureWidth) + if (_startPosX + _airbusWidth + Airbus.Step() < _pictureWidth) { - _startPosX += Plane.Step(); + _startPosX += Airbus.Step(); } - else _startPosX = _pictureWidth - _planeWidth; + else _startPosX = _pictureWidth - _airbusWidth; break; //влево case Left: - if (_startPosX - Plane.Step() >= 0) + if (_startPosX - Airbus.Step() >= 0) { - _startPosX -= Plane.Step(); + _startPosX -= Airbus.Step(); } else _startPosX = 0; break; //вверх case Up: - if (_startPosY - Plane.Step() >= 0) + if (_startPosY - Airbus.Step() >= 0) { - _startPosY -= Plane.Step(); + _startPosY -= Airbus.Step(); } else _startPosY = 0; break; //вниз case Down: - if (_startPosY + _planeHeight + Plane.Step() < _pictureHeight) + if (_startPosY + _airbusHeight + Airbus.Step() < _pictureHeight) { - _startPosY += Plane.Step(); + _startPosY += Airbus.Step(); } - else _startPosY = _pictureHeight - _planeWidth; + else _startPosY = _pictureHeight - _airbusWidth; break; } } @@ -105,7 +105,7 @@ public class DrawingPlane { // корпус - g.setColor(Plane.getBodyColor()); + g.setColor(Airbus.getBodyColor()); g.fillOval((int)_startPosX, (int)_startPosY + 20, 20, 20); g.fillRect((int)_startPosX + 8, (int)_startPosY + 20, 100, 20); @@ -154,19 +154,19 @@ public class DrawingPlane { { _pictureWidth = width; _pictureHeight = height; - if (_pictureWidth <= _planeWidth || _pictureHeight <= _planeHeight) + if (_pictureWidth <= _airbusWidth || _pictureHeight <= _airbusHeight) { _pictureWidth = null; _pictureHeight = null; return; } - if (_startPosX + _planeWidth > _pictureWidth) + if (_startPosX + _airbusWidth > _pictureWidth) { - _startPosX = _pictureWidth - _planeWidth; + _startPosX = _pictureWidth - _airbusWidth; } - if (_startPosY + _planeHeight > _pictureHeight) + if (_startPosY + _airbusHeight > _pictureHeight) { - _startPosY = _pictureHeight - _planeHeight; + _startPosY = _pictureHeight - _airbusHeight; } } } diff --git a/EntityPlane.java b/EntityAirbus.java similarity index 96% rename from EntityPlane.java rename to EntityAirbus.java index 12a5a8b..3218cba 100644 --- a/EntityPlane.java +++ b/EntityAirbus.java @@ -1,7 +1,7 @@ import java.awt.Color; import java.util.Random; -public class EntityPlane { +public class EntityAirbus { private int Speed = 0; private float Weight = 0; private Color BodyColor; diff --git a/FormPlane.java b/FormAirbus.java similarity index 84% rename from FormPlane.java rename to FormAirbus.java index 1d04e4b..69795d6 100644 --- a/FormPlane.java +++ b/FormAirbus.java @@ -3,12 +3,12 @@ import java.awt.*; import java.awt.event.*; import java.util.Random; -public class FormPlane extends JComponent +public class FormAirbus extends JComponent { - private DrawingPlane _plane; - private EntityPlane _entity; + private DrawingAirbus _plane; + private EntityAirbus _entity; - public FormPlane() + public FormAirbus() { JFrame formFrame = new JFrame("Plane"); formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -49,13 +49,13 @@ public class FormPlane extends JComponent createButton.addActionListener(e -> { Random rand = new Random(); - _plane = new DrawingPlane(); - _entity = new EntityPlane(); + _plane = new DrawingAirbus(); + _entity = new EntityAirbus(); _plane.Init(rand.nextInt( 400 + rand.nextInt(200)), 1000 + rand.nextInt(1000), Color.getHSBColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), rand.nextInt(3), _entity); _plane.SetPosition(10 + rand.nextInt(90), 10 + rand.nextInt(90), formFrame.getWidth(), formFrame.getHeight() - 75); - speedLabel.setText("Speed: " + _plane.Plane.getSpeed()); - weightLabel.setText("Weight: " + (int)_plane.Plane.getWeight()); - colorLabel.setText("Color: " + _plane.Plane.getBodyColor().getRed() + " " + _plane.Plane.getBodyColor().getGreen() + " " + _plane.Plane.getBodyColor().getBlue() ); + speedLabel.setText("Speed: " + _plane.Airbus.getSpeed()); + weightLabel.setText("Weight: " + (int)_plane.Airbus.getWeight()); + colorLabel.setText("Color: " + _plane.Airbus.getBodyColor().getRed() + " " + _plane.Airbus.getBodyColor().getGreen() + " " + _plane.Airbus.getBodyColor().getBlue() ); repaint(); }); @@ -101,7 +101,7 @@ public class FormPlane extends JComponent } public static void main(String[] args) { - new FormPlane(); + new FormAirbus(); } }