From 021b810748aaaf429036ae9b73a60eff71be026f Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Wed, 22 May 2024 01:05:19 +0400
Subject: [PATCH 1/9] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=963(=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/Drawnings/DrawningAirCraft.java | 13 +-
.../src/Drawnings/DrawningAirFighter.java | 9 +-
.../src/Drawnings/DrawningEngine.java | 6 +
.../src/Drawnings/DrawningLongEngine.java | 6 +
.../src/Drawnings/DrawningOvalEngine.java | 6 +
.../src/Entities/EntityAirCraft.java | 10 +
.../src/Entities/EntityAirFighter.java | 10 +
ProjectAirFighter/src/FormAirFighter.form | 131 -------------
ProjectAirFighter/src/FormAirFighter.java | 176 ------------------
ProjectAirFighter/src/Main.java | 12 +-
.../src/MovementStrategy/MoveToBorder.java | 6 +-
.../src/MovementStrategy/MoveToCenter.java | 3 +-
.../Drawnings/DrawningAirCraft$1.class | Bin 826 -> 826 bytes
.../Drawnings/DrawningAirCraft.class | Bin 6026 -> 6136 bytes
14 files changed, 60 insertions(+), 328 deletions(-)
delete mode 100644 ProjectAirFighter/src/FormAirFighter.form
delete mode 100644 ProjectAirFighter/src/FormAirFighter.java
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
index 3bb5bcd..9f102ac 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
@@ -7,7 +7,7 @@ import java.awt.*;
import java.util.Random;
public class DrawningAirCraft {
- private final EntityAirCraft entityAirCraft;
+ public Entities.EntityAirCraft entityAirCraft;
public EntityAirCraft getEntityAirCraft() {
return entityAirCraft;
@@ -20,11 +20,11 @@ public class DrawningAirCraft {
private int _drawingAirCraftWidth = 66;
private int _drawingAirCraftHeight = 74;
- public int GetPosX() {
+ public Integer GetPosX() {
return _startPosX;
}
- public int GetPosY() {
+ public Integer GetPosY() {
return _startPosY;
}
@@ -36,7 +36,7 @@ public class DrawningAirCraft {
return _drawingAirCraftHeight;
}
- private IDrawEngine drawEngine;
+ public IDrawEngine drawEngine;
public DrawningAirCraft(int speed, float weight, Color bodyColor, int engineType) {
entityAirCraft = new EntityAirCraft(speed, weight, bodyColor);
@@ -68,6 +68,11 @@ public class DrawningAirCraft {
_drawingAirCraftWidth = aircraftWidth;
}
+ public DrawningAirCraft(EntityAirCraft _entityAirCraft, IDrawEngine _drawEngine) {
+ entityAirCraft = _entityAirCraft;
+ drawEngine = _drawEngine;
+ }
+
public void setPosition(int x, int y) {
if (_pictureHeight == null || _pictureWidth == null)
return;
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
index aa62b56..9f44440 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
@@ -5,15 +5,16 @@ import Entities.EntityAirFighter;
import java.awt.*;
public class DrawningAirFighter extends DrawningAirCraft {
- private EntityAirFighter entityAirFighter;
-
public DrawningAirFighter(int speed, float weight, Color bodyColor, int engineType, Color additionalColor, boolean pgo, boolean rockets) {
super(speed, weight, bodyColor, engineType, 76, 80);
- entityAirFighter = new EntityAirFighter(speed, weight, bodyColor, additionalColor, pgo, rockets);
+ entityAirCraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, pgo, rockets);
}
+ public DrawningAirFighter(EntityAirFighter entity, IDrawEngine engine) {
+ super(entity, engine);
+ }
public void drawAirCraft(Graphics g) {
- if (entityAirFighter == null || _startPosX == null || _startPosY == null) {
+ if (entityAirCraft == null|| !(entityAirCraft instanceof EntityAirFighter entityAirFighter) || _startPosX == null || _startPosY == null) {
return;
}
super.drawAirCraft(g);
diff --git a/ProjectAirFighter/src/Drawnings/DrawningEngine.java b/ProjectAirFighter/src/Drawnings/DrawningEngine.java
index ded7e3f..acb4f6b 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningEngine.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningEngine.java
@@ -35,4 +35,10 @@ public class DrawningEngine implements IDrawEngine {
g2d.drawRect(_startX + 30, _startY + 17, 10, 2 );
}
}
+ @Override
+ public String toString() {
+ String buffer = "";
+ buffer += "Тип: обычные, Количество двигателей: " + _engineCount.getEnumNumber();
+ return buffer;
+ }
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningLongEngine.java b/ProjectAirFighter/src/Drawnings/DrawningLongEngine.java
index cbf1dc9..3a31622 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningLongEngine.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningLongEngine.java
@@ -35,4 +35,10 @@ public class DrawningLongEngine implements IDrawEngine {
g2d.drawRoundRect(_startX + 25, _startY + 17, 15, 2, 5, 5);
}
}
+ @Override
+ public String toString() {
+ String buffer = "";
+ buffer += "Тип: длиные, Количество двигателей: " + _engineCount.getEnumNumber();
+ return buffer;
+ }
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningOvalEngine.java b/ProjectAirFighter/src/Drawnings/DrawningOvalEngine.java
index 066274b..2bed099 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningOvalEngine.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningOvalEngine.java
@@ -35,4 +35,10 @@ public class DrawningOvalEngine implements IDrawEngine {
g2d.drawOval(_startX + 30, _startY + 17, 10, 2);
}
}
+ @Override
+ public String toString() {
+ String buffer = "";
+ buffer += "Тип: овальные, Количество двигателей: " + _engineCount.getEnumNumber();
+ return buffer;
+ }
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Entities/EntityAirCraft.java b/ProjectAirFighter/src/Entities/EntityAirCraft.java
index ae2634c..7313e3f 100644
--- a/ProjectAirFighter/src/Entities/EntityAirCraft.java
+++ b/ProjectAirFighter/src/Entities/EntityAirCraft.java
@@ -25,4 +25,14 @@ public class EntityAirCraft {
Weight = weight;
BodyColor = bodyColor;
}
+
+ @Override
+ public String toString() {
+ String buffer = "";
+ buffer += "Скорость: " + this.Speed;
+ buffer += ", Вес: " + this.Weight;
+ buffer += String.format(", Основной цвет : RGB{%d, %d, %d}",
+ this.BodyColor.getRed(), this.BodyColor.getGreen(), this.BodyColor.getBlue());
+ return buffer;
+ }
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Entities/EntityAirFighter.java b/ProjectAirFighter/src/Entities/EntityAirFighter.java
index 2098795..250ee19 100644
--- a/ProjectAirFighter/src/Entities/EntityAirFighter.java
+++ b/ProjectAirFighter/src/Entities/EntityAirFighter.java
@@ -21,4 +21,14 @@ public class EntityAirFighter extends EntityAirCraft {
Pgo = pgo;
Rockets = rockets;
}
+
+ @Override
+ public String toString() {
+ String buffer = super.toString();
+ buffer += String.format(", Дополнительный цвет : RGB{%d, %d, %d}",
+ this.AdditionalColor.getRed(), this.AdditionalColor.getGreen(), this.AdditionalColor.getBlue());
+ buffer += ", ПГО: " + this.Pgo;
+ buffer += ", Ракеты: " + this.Rockets;
+ return buffer;
+ }
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/FormAirFighter.form b/ProjectAirFighter/src/FormAirFighter.form
deleted file mode 100644
index fd0549c..0000000
--- a/ProjectAirFighter/src/FormAirFighter.form
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
diff --git a/ProjectAirFighter/src/FormAirFighter.java b/ProjectAirFighter/src/FormAirFighter.java
deleted file mode 100644
index cf00e67..0000000
--- a/ProjectAirFighter/src/FormAirFighter.java
+++ /dev/null
@@ -1,176 +0,0 @@
-import Drawnings.DrawningAirCraft;
-import Drawnings.DrawningAirFighter;
-import MovementStrategy.*;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.LinkedList;
-import java.util.Random;
-import java.util.List;
-
-public class FormAirFighter extends JFrame {
- protected DrawningAirCraft _drawningAirCraft;
- JPanel PanelWrapper;
- private JPanel PictureBox;
- private JButton buttonCreateAirFighter;
- private JButton buttonCreateAirCraft;
- private JButton buttonRight;
- private JButton buttonDown;
- private JButton buttonLeft;
- private JButton buttonUp;
- private JComboBox comboBoxStrategy;
- private JButton buttonStrategyStep;
- private AbstractStrategy _strategy;
- private List controls;
-
- private void createObject(String type) {
- Random random = new Random();
- switch (type) {
- case "Drawnings.DrawningAirCraft":
- _drawningAirCraft = new DrawningAirCraft(random.nextInt(30,100), random.nextInt(100,500),
- new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), random.nextInt(3));
- break;
- case "Drawnings.DrawningAirFighter":
- _drawningAirCraft = new DrawningAirFighter(random.nextInt(30,100), random.nextInt(100,500),
- new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), random.nextInt(3),
- new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
- random.nextBoolean(), random.nextBoolean());
- break;
- default:
- return;
- }
- _drawningAirCraft.setPictureSize(PictureBox.getWidth(), PictureBox.getHeight());
- _drawningAirCraft.setPosition(random.nextInt(25, 100),
- random.nextInt(25, 100));
- _strategy = null;
- comboBoxStrategy.setEnabled(true);
-
- Draw();
- }
-
- public FormAirFighter() {
- buttonUp.setName("buttonUp");
- buttonDown.setName("buttonDown");
- buttonLeft.setName("buttonLeft");
- buttonRight.setName("buttonRight");
-
- InitializeControlsRepaintList();
-
- buttonCreateAirFighter.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- createObject("Drawnings.DrawningAirFighter");
-
- }
- });
- buttonCreateAirCraft.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- createObject("Drawnings.DrawningAirCraft");
- }
- });
- ActionListener buttonMoveClickedListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String buttonName = ((JButton) e.getSource()).getName();
- boolean result = false;
-
- switch (buttonName) {
- case "buttonUp": {
- result = _drawningAirCraft.moveTransport(MovementDirection.Up);
- }
- break;
- case "buttonDown": {
- result = _drawningAirCraft.moveTransport(MovementDirection.Down);
- }
- break;
- case "buttonLeft": {
- result = _drawningAirCraft.moveTransport(MovementDirection.Left);
- }
- break;
- case "buttonRight": {
- result = _drawningAirCraft.moveTransport(MovementDirection.Right);
- }
- break;
- }
- if (result)
- Draw();
- }
- };
- buttonRight.addActionListener(buttonMoveClickedListener);
- buttonDown.addActionListener(buttonMoveClickedListener);
- buttonLeft.addActionListener(buttonMoveClickedListener);
- buttonUp.addActionListener(buttonMoveClickedListener);
- comboBoxStrategy.addItem("К центру");
- comboBoxStrategy.addItem("К краю");
- buttonStrategyStep.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (_drawningAirCraft == null)
- return;
- if (comboBoxStrategy.isEnabled()) {
- switch (comboBoxStrategy.getSelectedIndex()) {
- case 0:
- _strategy = new MoveToCenter();
- break;
- case 1:
- _strategy = new MoveToBorder();
- break;
-
- default:
- _strategy = null;
- break;
-
- }
- if (_strategy == null) {
- return;
- }
- _strategy.SetData(new MoveableAirCraft(_drawningAirCraft), PictureBox.getWidth(), PictureBox.getHeight());
- }
- if (_strategy == null) {
- return;
- }
- _strategy.MakeStep();
- Draw();
- comboBoxStrategy.setEnabled(false);
-
- if (_strategy.GetStatus() == StrategyStatus.Finish) {
- comboBoxStrategy.setEnabled(true);
- _strategy = null;
- }
- }
- });
- }
- private void Draw() {
- if (_drawningAirCraft.getEntityAirCraft() == null)
- return;
- if (PictureBox.getWidth() == 0 || PictureBox.getHeight() == 0) {
- return;
- }
- Graphics g = PictureBox.getGraphics();
- g.setColor(PictureBox.getBackground());
- g.fillRect(0,0, PictureBox.getWidth(), PictureBox.getHeight());
- _drawningAirCraft.drawAirCraft(g);
-
- RepaintControls();
- }
- private void RepaintControls() {
- for (JComponent control : controls) {
- control.repaint();
- }
- }
-
- private void InitializeControlsRepaintList() {
- controls = new LinkedList<>();
- controls.add(buttonCreateAirFighter);
- controls.add(buttonCreateAirCraft);
- controls.add(buttonUp);
- controls.add(buttonDown);
- controls.add(buttonLeft);
- controls.add(buttonRight);
- controls.add(comboBoxStrategy);
- controls.add(buttonStrategyStep);
- }
-}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Main.java b/ProjectAirFighter/src/Main.java
index e514ca2..d97dbd3 100644
--- a/ProjectAirFighter/src/Main.java
+++ b/ProjectAirFighter/src/Main.java
@@ -1,13 +1,7 @@
-import javax.swing.*;
+import Forms.FormAirCraftCollection;
public class Main {
public static void main(String[] args) {
- JFrame.setDefaultLookAndFeelDecorated(false);
- JFrame frame = new JFrame("Истребитель");
- frame.setContentPane(new FormAirFighter().PanelWrapper);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setLocation(500, 200);
- frame.pack();
- frame.setSize(700, 500);
- frame.setVisible(true);
+ FormAirCraftCollection formAirCraftCollection = new FormAirCraftCollection();
+ formAirCraftCollection.OpenFrame();
}
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/MovementStrategy/MoveToBorder.java b/ProjectAirFighter/src/MovementStrategy/MoveToBorder.java
index 52d6ad6..e6ce28b 100644
--- a/ProjectAirFighter/src/MovementStrategy/MoveToBorder.java
+++ b/ProjectAirFighter/src/MovementStrategy/MoveToBorder.java
@@ -1,18 +1,18 @@
package MovementStrategy;
public class MoveToBorder extends AbstractStrategy {
+ @Override
protected boolean IsTargetDestination()
{
var objParams = GetObjectParameters();
if (objParams == null) {
return false;
}
- return objParams.RightBorder() <= FieldWidth &&
- objParams.RightBorder() + GetStep() >= FieldWidth &&
- objParams.DownBorder() <= FieldHeight &&
+ return objParams.RightBorder() + GetStep() >= FieldWidth &&
objParams.DownBorder() + GetStep() >= FieldHeight;
}
+ @Override
protected void MoveToTarget()
{
var objParams = GetObjectParameters();
diff --git a/ProjectAirFighter/src/MovementStrategy/MoveToCenter.java b/ProjectAirFighter/src/MovementStrategy/MoveToCenter.java
index 8a314f8..0249179 100644
--- a/ProjectAirFighter/src/MovementStrategy/MoveToCenter.java
+++ b/ProjectAirFighter/src/MovementStrategy/MoveToCenter.java
@@ -1,6 +1,7 @@
package MovementStrategy;
public class MoveToCenter extends AbstractStrategy {
+ @Override
protected boolean IsTargetDestination()
{
var objParams = GetObjectParameters();
@@ -12,9 +13,9 @@ public class MoveToCenter extends AbstractStrategy {
objParams.ObjectMiddleVertical() - GetStep() <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical() + GetStep() >= FieldHeight / 2);
}
+ @Override
protected void MoveToTarget()
{
-
var objParams = GetObjectParameters();
if (objParams == null) {
return;
diff --git a/out/production/PIbd-14_Calimullin_A.R._AirFighter_Hard/Drawnings/DrawningAirCraft$1.class b/out/production/PIbd-14_Calimullin_A.R._AirFighter_Hard/Drawnings/DrawningAirCraft$1.class
index edb7f7bdd883b4804316eee468ce1aea1b147d38..52b10a90d60906ac434066a9a45d277f5d81f4ba 100644
GIT binary patch
delta 13
UcmdnRwu^1UOD4wL$*-6K04EFuSpWb4
delta 13
UcmdnRwu^1UOD4w5$*-6K04DeaRR910
diff --git a/out/production/PIbd-14_Calimullin_A.R._AirFighter_Hard/Drawnings/DrawningAirCraft.class b/out/production/PIbd-14_Calimullin_A.R._AirFighter_Hard/Drawnings/DrawningAirCraft.class
index 60add023fee43ba9e7edb08519f53841a9e83a4f..e2fa6d4ea906e3abd238cedcf431f499c049e926 100644
GIT binary patch
literal 6136
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
Date: Wed, 22 May 2024 01:06:16 +0400
Subject: [PATCH 2/9] =?UTF-8?q?=D0=B2=D0=BE=D1=80=D0=BA=D0=B8=D0=BD=D0=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../AbstractCompany.java | 58 +++++++
.../AirCraftAngar.java | 62 +++++++
.../CollectionGenericObjects/Constructor.java | 52 ++++++
.../ICollectionGenericObjects.java | 17 ++
.../MassiveGenericObjects.java | 90 ++++++++++
.../Drawnings/DrawningAbstractCompany.java | 125 ++++++++++++++
.../src/Drawnings/DrawningConstructor.java | 77 +++++++++
.../src/Drawnings/DrawningFormAirFighter.java | 69 ++++++++
.../src/Forms/FormAirCraftCollection.java | 161 ++++++++++++++++++
.../src/Forms/FormAirFighter.java | 112 ++++++++++++
.../src/Forms/FormConstructor.java | 90 ++++++++++
11 files changed, 913 insertions(+)
create mode 100644 ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
create mode 100644 ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
create mode 100644 ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
create mode 100644 ProjectAirFighter/src/CollectionGenericObjects/ICollectionGenericObjects.java
create mode 100644 ProjectAirFighter/src/CollectionGenericObjects/MassiveGenericObjects.java
create mode 100644 ProjectAirFighter/src/Drawnings/DrawningAbstractCompany.java
create mode 100644 ProjectAirFighter/src/Drawnings/DrawningConstructor.java
create mode 100644 ProjectAirFighter/src/Drawnings/DrawningFormAirFighter.java
create mode 100644 ProjectAirFighter/src/Forms/FormAirCraftCollection.java
create mode 100644 ProjectAirFighter/src/Forms/FormAirFighter.java
create mode 100644 ProjectAirFighter/src/Forms/FormConstructor.java
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java b/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
new file mode 100644
index 0000000..efd6ae5
--- /dev/null
+++ b/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
@@ -0,0 +1,58 @@
+package CollectionGenericObjects;
+
+import Drawnings.DrawningAirCraft;
+
+import java.awt.*;
+import java.util.Random;
+
+public abstract class AbstractCompany {
+ protected final int _placeSizeWidth = 210;
+ protected final int _placeSizeHeight = 120;
+ protected final int _pictureWidth;
+ protected final int _pictureHeight;
+ protected ICollectionGenericObjects _collection = null;
+ public int getMaxCount() {
+ return _pictureWidth * _pictureHeight / (_placeSizeWidth*_placeSizeHeight);
+ }
+ public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) {
+ this._pictureWidth = picWidth;
+ this._pictureHeight = picHeight;
+ this._collection = collection;
+ int maxCount = getMaxCount();
+ _collection.setMaxCount(maxCount);
+ }
+ public static int add(AbstractCompany company ,DrawningAirCraft airCraft) {
+ if (company._collection == null) {
+ return -1;
+ }
+ return company._collection.insert(airCraft);
+ }
+
+ public static DrawningAirCraft remove(AbstractCompany company, int position) {
+ if (company._collection == null) {
+ return null;
+ }
+ return company._collection.remove(position);
+ }
+ public DrawningAirCraft getRandomObject() {
+ if (_collection == null) {
+ return null;
+ }
+ Random rnd = new Random();
+ return _collection.get(rnd.nextInt(0, _collection.getCount() + 1));
+ }
+ public void show(Graphics g) {
+ drawBackground(g);
+ setObjectsPosition();
+ if (_collection == null) {
+ return;
+ }
+ for(int i = 0; i < _collection.getCount(); i++) {
+ if(_collection.get(i) != null) {
+ _collection.get(i).drawAirCraft(g);
+ }
+ }
+ }
+ protected abstract void drawBackground(Graphics g);
+ protected abstract void setObjectsPosition();
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
new file mode 100644
index 0000000..0fed8a5
--- /dev/null
+++ b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
@@ -0,0 +1,62 @@
+package CollectionGenericObjects;
+
+import Drawnings.DrawningAirCraft;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AirCraftAngar extends AbstractCompany {
+ private final List locCoord = new ArrayList<>();
+ private int numRows, numCols;
+ public AirCraftAngar(int picWidth, int picHeight, ICollectionGenericObjects collection) {
+ super(picWidth, picHeight, collection);
+ _collection.setMaxCount(30);
+
+ }
+ @Override
+ protected void drawBackground(Graphics g) {
+ Color backgroundColor = new Color(255, 255, 255);
+ g.setColor(backgroundColor);
+ g.fillRect(0, 0, _pictureWidth, _pictureHeight);
+
+ g.setColor(new Color(165, 42, 42)); // Brown
+ int offsetX = 10, offsetY = -5;
+ int x = 1 + offsetX, y = _pictureHeight - _placeSizeHeight + offsetY;
+ numRows = 0;
+ while (y >= 0) {
+ int numCols = 0;
+ while (x + _placeSizeWidth <= _pictureWidth) {
+ numCols++;
+ g.drawLine(x, y, x + _placeSizeWidth / 2, y);
+ g.drawLine(x, y, x, y + _placeSizeHeight + 4);
+ locCoord.add(new Point(x, y));
+ x += _placeSizeWidth + 2;
+ }
+ numRows++;
+ x = 1 + offsetX;
+ y -= _placeSizeHeight + 5 + offsetY;
+ }
+
+ }
+
+ @Override
+ protected void setObjectsPosition() {
+ if (locCoord == null || _collection == null) {
+ return;
+ }
+ int row = numRows - 1, col = numCols;
+ for (int i=0;i< _collection.getCount(); i++, col--) {
+ if (_collection.get(i) != null) {
+ _collection.get(i).setPictureSize(_pictureWidth, _pictureHeight);
+ _collection.get(i).setPosition((int)locCoord.get(row*numCols - col).getX() + 5,
+ (int)locCoord.get(row*numCols - col).getY() + 9);
+ if (col == 1) {
+ col = numCols + 1;
+ row--;
+ }
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
new file mode 100644
index 0000000..a60ef3f
--- /dev/null
+++ b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
@@ -0,0 +1,52 @@
+package CollectionGenericObjects;
+
+import Drawnings.DrawningAirCraft;
+import Drawnings.DrawningAirFighter;
+import Drawnings.IDrawEngine;
+import Entities.EntityAirCraft;
+import Entities.EntityAirFighter;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+public class Constructor {
+ private ArrayList entitiesList = new ArrayList<>();
+ private ArrayList engineList = new ArrayList<>();
+ public void addAirCraft(T obj) {
+ entitiesList.add(obj);
+ }
+ public void addAirCraft(U obj) {
+ engineList.add(obj);
+ }
+
+ public DrawningAirCraft getRandomAirCraft() {
+ Random rnd = new Random();
+ int entityIndex = rnd.nextInt(0, 3);
+ int engineIndex = rnd.nextInt(0, 3);
+
+ T entity = entitiesList.get(entityIndex);
+ U engine = engineList.get(engineIndex);
+
+ return (entity instanceof EntityAirFighter) ?
+ new DrawningAirFighter((EntityAirFighter) entity, engine) :
+ new DrawningAirCraft(entity, engine);
+ }
+
+ public String getEntityDescription(int index) {
+ if (index < 0 || index >= entitiesList.size()) {
+ return null;
+ }
+
+ T entity = entitiesList.get(index);
+ String entityClassName = (entity instanceof EntityAirFighter) ? "EntityAirFighter" : "EntityAirCraft";
+
+ return String.format("%s = %s", entityClassName, entity);
+ }
+
+ public String getEngineDescription(int index) {
+ if (index < 0 || index >= engineList.size()) {
+ return null;
+ }
+ return engineList.get(index).toString();
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/ICollectionGenericObjects.java b/ProjectAirFighter/src/CollectionGenericObjects/ICollectionGenericObjects.java
new file mode 100644
index 0000000..6320149
--- /dev/null
+++ b/ProjectAirFighter/src/CollectionGenericObjects/ICollectionGenericObjects.java
@@ -0,0 +1,17 @@
+package CollectionGenericObjects;
+
+import Drawnings.DrawningAirCraft;
+
+public interface ICollectionGenericObjects {
+ int getCount();
+
+ void setMaxCount(int count);
+
+ int insert(T obj);
+
+ int insert(T obj, int index);
+
+ T remove(int index);
+
+ T get(int index);
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/MassiveGenericObjects.java b/ProjectAirFighter/src/CollectionGenericObjects/MassiveGenericObjects.java
new file mode 100644
index 0000000..2475788
--- /dev/null
+++ b/ProjectAirFighter/src/CollectionGenericObjects/MassiveGenericObjects.java
@@ -0,0 +1,90 @@
+package CollectionGenericObjects;
+
+import Drawnings.DrawningAirCraft;
+import java.util.ArrayList;
+
+public class MassiveGenericObjects implements ICollectionGenericObjects {
+ private ArrayList _collection;
+ public MassiveGenericObjects() {
+ _collection = new ArrayList<>();
+
+ }
+ int maxCount = 0;
+ int realSize = 0;
+ @Override
+ public int getCount() {
+ return _collection.size();
+ }
+ @Override
+ public int insert(T obj) {
+ return insert(obj, 0);
+ }
+
+ @Override
+ public int insert(T obj, int position) {
+ if (position > maxCount|| position < 0) {
+ return -1;
+ }
+
+ for (int i = position; i < maxCount; i++) {
+ if (_collection.get(i) == null) {
+ _collection.set(i, obj);
+ realSize++;
+ return i;
+ }
+ }
+ for (int i = position; i > 0; i--) {
+ if (_collection.get(i) == null) {
+ _collection.set(i, obj);
+ realSize++;
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public T remove(int position) {
+ if (position < 0 || position >= maxCount) {
+ return null;
+ }
+ if (_collection.get(position) != null) {
+ T bf = _collection.get(position);
+ _collection.set(position, null);
+ --realSize;
+ return bf;
+ }
+ return null;
+ }
+
+ @Override
+ public T get(int position) {
+ if (position >= 0 && position < _collection.size()) {
+ return _collection.get(position);
+ }
+ else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setMaxCount(int count) {
+ if (count > 0) {
+ if (!_collection.isEmpty()) {
+ ArrayList bfLoc = new ArrayList<>(count);
+ bfLoc.addAll(0, _collection);
+ _collection = bfLoc;
+ for (int i = 0; i < count - maxCount; i++) {
+ _collection.add(null);
+ }
+ } else {
+ _collection = new ArrayList<>(count);
+ for (int i = 0; i < count; i++) {
+ _collection.add(null);
+ }
+
+ }
+ maxCount = count;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAbstractCompany.java b/ProjectAirFighter/src/Drawnings/DrawningAbstractCompany.java
new file mode 100644
index 0000000..4a34f66
--- /dev/null
+++ b/ProjectAirFighter/src/Drawnings/DrawningAbstractCompany.java
@@ -0,0 +1,125 @@
+package Drawnings;
+
+import CollectionGenericObjects.AbstractCompany;
+import CollectionGenericObjects.AirCraftAngar;
+import CollectionGenericObjects.MassiveGenericObjects;
+import Forms.FormAirFighter;
+import Forms.FormConstructor;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.WindowEvent;
+import java.util.Random;
+
+public class DrawningAbstractCompany extends JComponent {
+ private AbstractCompany _company = null;
+ public void collectionComboBox_SelectedIndexChanged(JComboBox obj, int width, int height) {
+ switch (obj.getSelectedIndex()) {
+ case 1:
+ _company = new AirCraftAngar(width, height, new MassiveGenericObjects());
+ break;
+ default:
+ break;
+ }
+ }
+ public void createObject(int type, JFrame obj) {
+ if (_company == null) {
+ return;
+ }
+ DrawningAirCraft _drawningAirCraft;
+ Random random = new Random();
+ switch (type) {
+ case 0:
+ _drawningAirCraft = new DrawningAirCraft(random.nextInt(30, 100), random.nextInt(100,500),
+ getColorR(obj, random), random.nextInt(3));
+ break;
+ case 1:
+ _drawningAirCraft = new DrawningAirFighter(random.nextInt(30, 100), random.nextInt(100,500),
+ getColorR(obj, random), random.nextInt(3),
+ getColorR(obj, random),
+ random.nextBoolean(), random.nextBoolean());
+ break;
+ default:
+ return;
+ }
+ if (AbstractCompany.add(_company, _drawningAirCraft) != -1) {
+ JOptionPane.showMessageDialog(obj, "Объект добавлен");
+ }
+ else {
+ JOptionPane.showMessageDialog(obj, "Не удалось добавить объект");
+ }
+ }
+ Color getColorR(JFrame obj, Random rnd) {
+ Color color = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
+ if (obj == null) {
+ return color;
+ }
+ JColorChooser colorChooser = new JColorChooser();
+ colorChooser.setColor(color);
+ return JColorChooser.showDialog(obj, "Выберите цвет", color);
+ }
+
+ public void deleteButtonAction(int val, Frame obj) {
+ if (_company == null) {
+ return;
+ }
+ int result = JOptionPane.showConfirmDialog(
+ obj,
+ "Удалить объект?",
+ "Подтверждение",
+ JOptionPane.YES_NO_OPTION);
+ if (result == JOptionPane.YES_OPTION) {
+ if (AbstractCompany.remove(_company, val) != null) {
+ JOptionPane.showMessageDialog(obj, "Выполнено");
+ } else {
+ JOptionPane.showMessageDialog(obj, "Удаление не удалось");
+ }
+ }
+ }
+ public void goToCheckButtonAction() {
+ if (_company == null) {
+ return;
+ }
+ DrawningAirCraft airCraft = null;
+ int counter = 100;
+ while (airCraft == null && counter > 0) {
+ airCraft = _company.getRandomObject();
+ --counter;
+ }
+ if (airCraft == null) {
+ return;
+ }
+ FormAirFighter formAirFighter = new FormAirFighter();
+ formAirFighter.setDrawningAirCraft(airCraft);
+ formAirFighter.OpenFrame();
+ }
+
+ private DrawningAirCraft createObject;
+ public void getObjFromConstructor(JFrame obj) {
+ if (_company == null) {
+ return;
+ }
+ FormConstructor formConstructor = new FormConstructor();
+ formConstructor.OpenFrame();
+
+ formConstructor.getAddButton().addActionListener(e -> {
+ createObject = formConstructor.getConstructor().getObj();
+ if (AbstractCompany.add(_company, createObject) != -1) {
+ JOptionPane.showMessageDialog(obj, "Выполнено");
+
+ } else {
+ JOptionPane.showMessageDialog(obj, "Добавление не удалось");
+ }
+ obj.repaint();
+ formConstructor.getjFrameConstructor().dispatchEvent(new WindowEvent(formConstructor.getjFrameConstructor(), WindowEvent.WINDOW_CLOSING));
+ });
+ }
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ if (_company == null) {
+ return;
+ }
+ _company.show(g);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
new file mode 100644
index 0000000..55af2ff
--- /dev/null
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -0,0 +1,77 @@
+package Drawnings;
+
+import CollectionGenericObjects.Constructor;
+import Entities.EntityAirCraft;
+import Entities.EntityAirFighter;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.Random;
+
+public class DrawningConstructor extends JComponent {
+ Constructor constructor = new Constructor<>();
+ private DrawningAirCraft obj;
+ public DrawningAirCraft getObj() {
+ return obj;
+ }
+ public DrawningConstructor() {
+ for (int i = 0; i < 3; i++) {
+ EntityAirCraft _entityAirCraft = null;
+ IDrawEngine _drawEngine = null;
+ Random rnd = new Random();
+ int paddlesType = rnd.nextInt(3);
+ switch (paddlesType) {
+ case 0:
+ _drawEngine = new DrawningEngine();
+ break;
+ case 1:
+ _drawEngine = new DrawningOvalEngine();
+ break;
+ case 2:
+ _drawEngine = new DrawningLongEngine();
+ break;
+ }
+ int engineCount = rnd.nextInt(1,4);
+ _drawEngine.setNumber(engineCount);
+
+ int typeBoat = rnd.nextInt(0,2);
+
+ switch (typeBoat) {
+ case 0:
+ _entityAirCraft = new EntityAirCraft(rnd.nextInt(30,100), rnd.nextInt(100,500),
+ new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
+ break;
+ case 1:
+ _entityAirCraft = new EntityAirFighter(rnd.nextInt(30,100), rnd.nextInt(100,500),
+ new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)),
+ new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)),
+ rnd.nextBoolean(), rnd.nextBoolean());
+ break;
+ }
+ constructor.addAirCraft(_entityAirCraft);
+ constructor.addAirCraft(_drawEngine);
+ }
+ obj = constructor.getRandomAirCraft();
+
+ }
+ public void reCreateObj() {
+ obj = constructor.getRandomAirCraft();
+ }
+
+ public String getEntityString(int index) {
+ return constructor.getEntityDescription(index);
+ }
+ public String getEngineString(int index) {
+ return constructor.getEngineDescription(index);
+ }
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ if (obj != null) {
+ obj.setPosition(10, 30);
+ obj.setPictureSize(400, 300);
+ obj.drawAirCraft(g);
+ }
+ super.repaint();
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningFormAirFighter.java b/ProjectAirFighter/src/Drawnings/DrawningFormAirFighter.java
new file mode 100644
index 0000000..e502bb6
--- /dev/null
+++ b/ProjectAirFighter/src/Drawnings/DrawningFormAirFighter.java
@@ -0,0 +1,69 @@
+package Drawnings;
+
+import MovementStrategy.*;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class DrawningFormAirFighter extends JComponent {
+ DrawningAirCraft drawningAirCraft;
+
+ private int _pictureHeight = -1;
+ private int _pictureWidth = -1;
+ private AbstractStrategy _strategy;
+ public void setDrawningAirCraft(DrawningAirCraft drawningAirCraft) {
+ this.drawningAirCraft = drawningAirCraft;
+ }
+
+ public boolean setPictureSize(int width, int height) {
+ if (drawningAirCraft.GetHeight() > height || drawningAirCraft.GetWidth() > width)
+ return false;
+ _pictureHeight = height;
+ _pictureWidth = width;
+ return true;
+ }
+ public void buttonStrategyStep(JComboBox comboBox) {
+ if (drawningAirCraft == null)
+ return;
+ if (comboBox.isEnabled()) {
+ switch (comboBox.getSelectedIndex()) {
+ case 0:
+ _strategy = new MoveToCenter();
+ break;
+ case 1:
+ _strategy = new MoveToBorder();
+ break;
+ default:
+ _strategy = null;
+ break;
+ }
+ if (_strategy == null) {
+ return;
+ }
+ _strategy.SetData(new MoveableAirCraft(drawningAirCraft), _pictureWidth, _pictureHeight);
+ }
+ if (_strategy == null) {
+ return;
+ }
+ comboBox.setEnabled(false);
+ _strategy.MakeStep();
+ if (_strategy.GetStatus() == StrategyStatus.Finish) {
+ comboBox.setEnabled(true);
+ _strategy = null;
+ }
+
+ }
+ public void MoveButtonsAction(MovementDirection direction) {
+ if (drawningAirCraft == null)
+ return;
+ drawningAirCraft.moveTransport(direction);
+ }
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ if (drawningAirCraft == null) {
+ return;
+ }
+ drawningAirCraft.drawAirCraft(g);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Forms/FormAirCraftCollection.java b/ProjectAirFighter/src/Forms/FormAirCraftCollection.java
new file mode 100644
index 0000000..85530a0
--- /dev/null
+++ b/ProjectAirFighter/src/Forms/FormAirCraftCollection.java
@@ -0,0 +1,161 @@
+package Forms;
+
+import Drawnings.DrawningAbstractCompany;
+import javax.swing.*;
+import javax.swing.text.NumberFormatter;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.text.NumberFormat;
+
+public class FormAirCraftCollection extends JFrame {
+ final private JFrame jFrameCollectionAirCraft = new JFrame();
+ final private DrawningAbstractCompany _company = new DrawningAbstractCompany();
+ final private JButton refreshButton = new JButton("Обновить");
+ final private JPanel refreshPanel = new JPanel();
+ final private String[] listOfComboBox = {
+
+ "",
+ "Хранилище"
+ };
+ final private JComboBox comboBoxSelectorCompany = new JComboBox<>(listOfComboBox);
+ final private JPanel comboBoxPanel = new JPanel();
+ final private JPanel toolsPanel = new JPanel();
+ final private JLabel toolsNameLabel = new JLabel("Инструменты");
+ final private JPanel labelPanel = new JPanel();
+ final private JButton buttonAddAirCraft = new JButton("Добавить самолёт");
+ final private JButton buttonAddAirFighter = new JButton("Добавить истребитель");
+ final private JPanel addBoatPanel = new JPanel();
+ final private JPanel addCatamaranPanel = new JPanel();
+ final private JButton buttonRemove = new JButton("Удалить самолёт");
+ final private JPanel removePanel = new JPanel();
+ final private JButton goToCheckButton = new JButton("Отправить на тесты");
+ final private JPanel goToCheckPanel = new JPanel();
+ final private JPanel addFromConstructorPanel = new JPanel();
+ final private JButton addFromConstructorButton = new JButton("Добавить из конструктора");
+
+ public void OpenFrame() {
+
+ jFrameCollectionAirCraft.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ Toolkit tolls = Toolkit.getDefaultToolkit();
+ Dimension dimension = tolls.getScreenSize();
+ jFrameCollectionAirCraft.setBounds(dimension.width / 2 - 250, dimension.height / 2 - 250,
+ 1200, 665);
+ jFrameCollectionAirCraft.setTitle("Коллекция самолётов");
+
+ toolsPanel.setBackground(Color.BLACK);
+ labelPanel.setSize(new Dimension(100, 20));
+ labelPanel.add(toolsNameLabel);
+
+ comboBoxPanel.setLayout(new BorderLayout());
+ comboBoxPanel.setSize(new Dimension(130, 30));
+ comboBoxPanel.add(comboBoxSelectorCompany, BorderLayout.CENTER);
+
+ addBoatPanel.setLayout(new BorderLayout());
+ addBoatPanel.setSize(170, 40);
+ addBoatPanel.add(buttonAddAirCraft, BorderLayout.CENTER);
+
+ addCatamaranPanel.setLayout(new BorderLayout());
+ addCatamaranPanel.setSize(170, 40);
+ addCatamaranPanel.add(buttonAddAirFighter, BorderLayout.CENTER);
+
+ removePanel.setLayout(new BorderLayout());
+ removePanel.setSize(170, 40);
+ removePanel.add(buttonRemove, BorderLayout.CENTER);
+
+ goToCheckPanel.setLayout(new BorderLayout());
+ goToCheckPanel.setSize(170, 40);
+ goToCheckPanel.add(goToCheckButton, BorderLayout.CENTER);
+
+ refreshPanel.setLayout(new BorderLayout());
+ refreshPanel.setSize(170, 40);
+ refreshPanel.add(refreshButton, BorderLayout.CENTER);
+
+ addFromConstructorPanel.setLayout(new BorderLayout());
+ addFromConstructorPanel.setSize(170, 40);
+ addFromConstructorPanel.add(addFromConstructorButton, BorderLayout.CENTER);
+
+ NumberFormat format = NumberFormat.getInstance();
+ NumberFormatter formatter = new NumberFormatter(format);
+ formatter.setValueClass(Integer.class);
+ formatter.setMinimum(0);
+ formatter.setMaximum(100);
+ formatter.setAllowsInvalid(true);
+ formatter.setCommitsOnValidEdit(true);
+
+ JTextField textBoxPosition = new JFormattedTextField(formatter);
+ JPanel textBoxPanel = new JPanel();
+ textBoxPanel.setLayout(new BorderLayout());
+ textBoxPanel.setSize(170, 40);
+ textBoxPanel.add(textBoxPosition, BorderLayout.CENTER);
+
+ jFrameCollectionAirCraft.add(toolsPanel);
+ jFrameCollectionAirCraft.add(labelPanel);
+ jFrameCollectionAirCraft.add(comboBoxPanel);
+ jFrameCollectionAirCraft.add(addBoatPanel);
+ jFrameCollectionAirCraft.add(addCatamaranPanel);
+ jFrameCollectionAirCraft.add(textBoxPanel);
+ jFrameCollectionAirCraft.add(removePanel);
+ jFrameCollectionAirCraft.add(goToCheckPanel);
+ jFrameCollectionAirCraft.add(refreshPanel);
+ jFrameCollectionAirCraft.add(addFromConstructorPanel);
+ jFrameCollectionAirCraft.add(_company);
+
+ jFrameCollectionAirCraft.addComponentListener(new ComponentAdapter() {
+ public void componentResized(ComponentEvent componentEvent) {
+ labelPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 210, 0);
+ toolsPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 233, 0);
+ comboBoxPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 30);
+ addBoatPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 70);
+ addCatamaranPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 120);
+ textBoxPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 220);
+ removePanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 260);
+ goToCheckPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 300);
+ refreshPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 340);
+ addFromConstructorPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 170);
+ toolsPanel.setSize(new Dimension(10, jFrameCollectionAirCraft.getHeight()));
+
+ jFrameCollectionAirCraft.repaint();
+ }
+ });
+
+ comboBoxSelectorCompany.addActionListener(e -> {
+
+ _company.collectionComboBox_SelectedIndexChanged(comboBoxSelectorCompany,
+ jFrameCollectionAirCraft.getWidth() - 233, jFrameCollectionAirCraft.getHeight());
+ jFrameCollectionAirCraft.repaint();
+
+ });
+ buttonAddAirCraft.addActionListener(e -> {
+ _company.createObject(0, jFrameCollectionAirCraft);
+ jFrameCollectionAirCraft.repaint();
+ });
+ buttonAddAirFighter.addActionListener(e -> {
+ _company.createObject(1, jFrameCollectionAirCraft);
+ jFrameCollectionAirCraft.repaint();
+ });
+
+ buttonRemove.addActionListener(e -> {
+ if (!textBoxPosition.getText().isEmpty()) {
+ if (Integer.parseInt(textBoxPosition.getText()) <= 99
+ && Integer.parseInt(textBoxPosition.getText()) >= 0) {
+ int pos = Integer.parseInt(textBoxPosition.getText());
+ _company.deleteButtonAction(pos, jFrameCollectionAirCraft);
+ }
+ }
+ jFrameCollectionAirCraft.repaint();
+
+ });
+ refreshButton.addActionListener(e -> {
+ jFrameCollectionAirCraft.repaint();
+ });
+ goToCheckButton.addActionListener(e -> {
+ _company.goToCheckButtonAction();
+ jFrameCollectionAirCraft.repaint();
+ });
+ addFromConstructorButton.addActionListener(e -> {
+ _company.getObjFromConstructor(jFrameCollectionAirCraft);
+ });
+ jFrameCollectionAirCraft.setVisible(true);
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Forms/FormAirFighter.java b/ProjectAirFighter/src/Forms/FormAirFighter.java
new file mode 100644
index 0000000..e2352ae
--- /dev/null
+++ b/ProjectAirFighter/src/Forms/FormAirFighter.java
@@ -0,0 +1,112 @@
+package Forms;
+
+import Drawnings.*;
+import MovementStrategy.*;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+
+public class FormAirFighter extends JFrame {
+ final private JFrame JFrameAirFighter = new JFrame();
+ final private JButton buttonRight = new JButton(new ImageIcon("ProjectAirFighter\\Resources\\arrowRight.png"));
+ final private JPanel RightPanel = new JPanel();
+ final private JButton buttonDown = new JButton(new ImageIcon("ProjectAirFighter\\Resources\\arrowDown.png"));
+ final private JPanel DownPanel = new JPanel();
+ final private JButton buttonLeft = new JButton(new ImageIcon("ProjectAirFighter\\Resources\\arrowLeft.png"));
+ final private JPanel LeftPanel = new JPanel();
+ final private JButton buttonUp = new JButton(new ImageIcon("ProjectAirFighter\\Resources\\arrowUp.png"));
+
+ final private JPanel UpPanel = new JPanel();
+ final private String [] itemsComboBox = {
+ "К центру",
+ "К краю"
+ };
+ final private JComboBox comboBoxStrategy =new JComboBox<>(itemsComboBox);
+ final private JButton buttonStrategyStep = new JButton("Шаг");
+ final private JPanel StrategyPanel = new JPanel(new BorderLayout());
+
+ final private DrawningFormAirFighter form = new DrawningFormAirFighter();
+ public void setDrawningAirCraft(DrawningAirCraft airCraft) {form.setDrawningAirCraft(airCraft);}
+ public void OpenFrame() {
+ JFrameAirFighter.setVisible(true);
+ Toolkit tolls = Toolkit.getDefaultToolkit();
+ Dimension dimension = tolls.getScreenSize();
+ JFrameAirFighter.setBounds(dimension.width / 2 - 250, dimension.height / 2 - 250,
+ 970, 700);
+ JFrameAirFighter.setTitle("Истребитель");
+
+ comboBoxStrategy.setPreferredSize(new Dimension(100, 35));
+ buttonStrategyStep.setPreferredSize(new Dimension(100, 35));
+ StrategyPanel.setSize(100, 70);
+ StrategyPanel.add(comboBoxStrategy, BorderLayout.NORTH);
+ StrategyPanel.add(buttonStrategyStep, BorderLayout.SOUTH);
+
+
+ UpPanel.setSize(30, 30);
+ buttonUp.setPreferredSize(new Dimension(30, 30));
+ UpPanel.add(buttonUp, BorderLayout.CENTER);
+
+ DownPanel.setSize(30, 30);
+ buttonDown.setPreferredSize(new Dimension(30, 30));
+ DownPanel.add(buttonDown, BorderLayout.CENTER);
+
+ RightPanel.setSize(30, 30);
+ buttonRight.setPreferredSize(new Dimension(30, 30));
+ RightPanel.add(buttonRight, BorderLayout.CENTER);
+
+ LeftPanel.setSize(30, 30);
+ buttonLeft.setPreferredSize(new Dimension(30, 30));
+ LeftPanel.add(buttonLeft, BorderLayout.CENTER);
+
+ JFrameAirFighter.add(StrategyPanel);
+ JFrameAirFighter.add(UpPanel);
+ JFrameAirFighter.add(DownPanel);
+ JFrameAirFighter.add(RightPanel);
+ JFrameAirFighter.add(LeftPanel);
+ JFrameAirFighter.add(form);
+
+ JFrameAirFighter.addComponentListener(new ComponentAdapter() {
+ public void componentResized(ComponentEvent e) {
+ StrategyPanel.setLocation(JFrameAirFighter.getWidth() - 100, 0);
+ UpPanel.setLocation(JFrameAirFighter.getWidth() - 80, JFrameAirFighter.getHeight()-100);
+ DownPanel.setLocation(JFrameAirFighter.getWidth() - 80, JFrameAirFighter.getHeight()-70);
+ RightPanel.setLocation(JFrameAirFighter.getWidth() - 45, JFrameAirFighter.getHeight()-70);
+ LeftPanel.setLocation(JFrameAirFighter.getWidth() - 115, JFrameAirFighter.getHeight()-70);
+
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ JFrameAirFighter.repaint();
+
+ }
+
+ });
+
+ buttonUp.addActionListener(e -> {
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ form.MoveButtonsAction(MovementDirection.Up);
+ JFrameAirFighter.repaint();
+ });
+
+ buttonDown.addActionListener(e -> {
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ form.MoveButtonsAction(MovementDirection.Down);
+ JFrameAirFighter.repaint();
+ });
+ buttonLeft.addActionListener(e -> {
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ form.MoveButtonsAction(MovementDirection.Left);
+ JFrameAirFighter.repaint();
+ });
+ buttonRight.addActionListener(e -> {
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ form.MoveButtonsAction(MovementDirection.Right);
+ JFrameAirFighter.repaint();
+ });
+ buttonStrategyStep.addActionListener(e -> {
+ form.setPictureSize(JFrameAirFighter.getWidth(), JFrameAirFighter.getHeight());
+ form.buttonStrategyStep(comboBoxStrategy);
+ JFrameAirFighter.repaint();
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Forms/FormConstructor.java b/ProjectAirFighter/src/Forms/FormConstructor.java
new file mode 100644
index 0000000..975a148
--- /dev/null
+++ b/ProjectAirFighter/src/Forms/FormConstructor.java
@@ -0,0 +1,90 @@
+package Forms;
+
+import Drawnings.DrawningConstructor;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+public class FormConstructor extends JFrame {
+ private JFrame jFrameConstructor = new JFrame();
+ public JFrame getjFrameConstructor() {
+ return jFrameConstructor;
+ }
+ private JButton addButton = new JButton("Добавить объект");
+ public JButton getAddButton() {
+ return addButton;
+ }
+ public JButton reCreateButton = new JButton("Пересоздать");
+ private final DrawningConstructor constructor = new DrawningConstructor();
+ public DrawningConstructor getConstructor() {
+ return constructor;
+ }
+ JPanel entitiesInfoPanel = new JPanel();
+ JLabel firstEntityLabel = new JLabel();
+ JLabel secondEntityLabel = new JLabel();
+ JLabel thirdEntityLabel = new JLabel();
+
+ JPanel paddlesInfoPanel = new JPanel();
+ JLabel firstPaddlesLabel = new JLabel();
+ JLabel secondPaddlesLabel = new JLabel();
+ JLabel thirdPaddlesLabel = new JLabel();
+
+ public void OpenFrame() {
+
+ Toolkit tolls = Toolkit.getDefaultToolkit();
+ Dimension dimension = tolls.getScreenSize();
+ jFrameConstructor.setBounds(dimension.width / 2 - 250, dimension.height / 2 - 250,
+ 800, 300);
+ jFrameConstructor.setLayout(new BorderLayout());
+
+ firstEntityLabel.setText(constructor.getEntityString(0));
+ secondEntityLabel.setText(constructor.getEntityString(1));
+ thirdEntityLabel.setText(constructor.getEntityString(2));
+
+ entitiesInfoPanel.setLayout(new BoxLayout(entitiesInfoPanel, BoxLayout.Y_AXIS));
+ entitiesInfoPanel.setBorder(BorderFactory.createTitledBorder("Entities"));
+ entitiesInfoPanel.setSize(500, 130);
+ entitiesInfoPanel.setLocation(150, 10);
+ entitiesInfoPanel.add(firstEntityLabel);
+ entitiesInfoPanel.add(secondEntityLabel);
+ entitiesInfoPanel.add(thirdEntityLabel);
+
+ firstPaddlesLabel.setText(constructor.getEngineString(0));
+ secondPaddlesLabel.setText(constructor.getEngineString(1));
+ thirdPaddlesLabel.setText(constructor.getEngineString(2));
+
+
+ paddlesInfoPanel.setLayout(new BoxLayout(paddlesInfoPanel, BoxLayout.Y_AXIS));
+ paddlesInfoPanel.setBorder(BorderFactory.createTitledBorder("Engine"));
+ paddlesInfoPanel.setSize(500, 130);
+ paddlesInfoPanel.setLocation(150, 150);
+ paddlesInfoPanel.add(firstPaddlesLabel);
+ paddlesInfoPanel.add(secondPaddlesLabel);
+ paddlesInfoPanel.add(thirdPaddlesLabel);
+
+ addButton.setBounds(0, jFrameConstructor.getHeight() - 105, 150, 50);
+ reCreateButton.setBounds(0, jFrameConstructor.getHeight() - 135, 150, 30);
+
+ jFrameConstructor.add(paddlesInfoPanel);
+ jFrameConstructor.add(entitiesInfoPanel);
+ jFrameConstructor.add(addButton);
+ jFrameConstructor.add(reCreateButton);
+ jFrameConstructor.add(constructor);
+ jFrameConstructor.revalidate();
+ jFrameConstructor.repaint();
+
+ jFrameConstructor.addComponentListener(new ComponentAdapter() {
+ public void componentResized(ComponentEvent componentEvent) {
+ addButton.setLocation(0, jFrameConstructor.getSize().height - 105);
+ reCreateButton.setLocation(0, jFrameConstructor.getSize().height - 135);
+ }
+ });
+ reCreateButton.addActionListener(e -> {
+ constructor.reCreateObj();
+ jFrameConstructor.repaint();
+ });
+ jFrameConstructor.setVisible(true);
+ }
+}
\ No newline at end of file
--
2.25.1
From e714e00fdb2586df1b7e8cc8e3f702551926d918 Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sat, 15 Jun 2024 20:40:11 +0400
Subject: [PATCH 3/9] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B3?=
=?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/Drawnings/DrawningConstructor.java | 7 +++--
.../src/Forms/FormAirCraftCollection.java | 24 +++++++--------
.../src/Forms/FormConstructor.java | 30 +++++++++----------
3 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
index 55af2ff..c6d4aed 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -31,18 +31,19 @@ public class DrawningConstructor extends JComponent {
_drawEngine = new DrawningLongEngine();
break;
}
- int engineCount = rnd.nextInt(1,4);
+ int[] countengine = {2, 4, 6};
+ int engineCount = countengine[rnd.nextInt(countengine.length)];
_drawEngine.setNumber(engineCount);
int typeBoat = rnd.nextInt(0,2);
switch (typeBoat) {
case 0:
- _entityAirCraft = new EntityAirCraft(rnd.nextInt(30,100), rnd.nextInt(100,500),
+ _entityAirCraft = new EntityAirCraft(rnd.nextInt(70 - 30) + 30, rnd.nextInt(500 - 100) + 100,
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
break;
case 1:
- _entityAirCraft = new EntityAirFighter(rnd.nextInt(30,100), rnd.nextInt(100,500),
+ _entityAirCraft = new EntityAirFighter(rnd.nextInt(70 - 30) + 30, rnd.nextInt(500 - 100) + 100,
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)),
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)),
rnd.nextBoolean(), rnd.nextBoolean());
diff --git a/ProjectAirFighter/src/Forms/FormAirCraftCollection.java b/ProjectAirFighter/src/Forms/FormAirCraftCollection.java
index 85530a0..500f349 100644
--- a/ProjectAirFighter/src/Forms/FormAirCraftCollection.java
+++ b/ProjectAirFighter/src/Forms/FormAirCraftCollection.java
@@ -25,8 +25,8 @@ public class FormAirCraftCollection extends JFrame {
final private JPanel labelPanel = new JPanel();
final private JButton buttonAddAirCraft = new JButton("Добавить самолёт");
final private JButton buttonAddAirFighter = new JButton("Добавить истребитель");
- final private JPanel addBoatPanel = new JPanel();
- final private JPanel addCatamaranPanel = new JPanel();
+ final private JPanel addAirCraftPanel = new JPanel();
+ final private JPanel addAirFighterPanel = new JPanel();
final private JButton buttonRemove = new JButton("Удалить самолёт");
final private JPanel removePanel = new JPanel();
final private JButton goToCheckButton = new JButton("Отправить на тесты");
@@ -51,13 +51,13 @@ public class FormAirCraftCollection extends JFrame {
comboBoxPanel.setSize(new Dimension(130, 30));
comboBoxPanel.add(comboBoxSelectorCompany, BorderLayout.CENTER);
- addBoatPanel.setLayout(new BorderLayout());
- addBoatPanel.setSize(170, 40);
- addBoatPanel.add(buttonAddAirCraft, BorderLayout.CENTER);
+ addAirCraftPanel.setLayout(new BorderLayout());
+ addAirCraftPanel.setSize(170, 40);
+ addAirCraftPanel.add(buttonAddAirCraft, BorderLayout.CENTER);
- addCatamaranPanel.setLayout(new BorderLayout());
- addCatamaranPanel.setSize(170, 40);
- addCatamaranPanel.add(buttonAddAirFighter, BorderLayout.CENTER);
+ addAirFighterPanel.setLayout(new BorderLayout());
+ addAirFighterPanel.setSize(170, 40);
+ addAirFighterPanel.add(buttonAddAirFighter, BorderLayout.CENTER);
removePanel.setLayout(new BorderLayout());
removePanel.setSize(170, 40);
@@ -92,8 +92,8 @@ public class FormAirCraftCollection extends JFrame {
jFrameCollectionAirCraft.add(toolsPanel);
jFrameCollectionAirCraft.add(labelPanel);
jFrameCollectionAirCraft.add(comboBoxPanel);
- jFrameCollectionAirCraft.add(addBoatPanel);
- jFrameCollectionAirCraft.add(addCatamaranPanel);
+ jFrameCollectionAirCraft.add(addAirCraftPanel);
+ jFrameCollectionAirCraft.add(addAirFighterPanel);
jFrameCollectionAirCraft.add(textBoxPanel);
jFrameCollectionAirCraft.add(removePanel);
jFrameCollectionAirCraft.add(goToCheckPanel);
@@ -106,8 +106,8 @@ public class FormAirCraftCollection extends JFrame {
labelPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 210, 0);
toolsPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 233, 0);
comboBoxPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 30);
- addBoatPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 70);
- addCatamaranPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 120);
+ addAirCraftPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 70);
+ addAirFighterPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 120);
textBoxPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 220);
removePanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 260);
goToCheckPanel.setLocation(jFrameCollectionAirCraft.getWidth() - 200, 300);
diff --git a/ProjectAirFighter/src/Forms/FormConstructor.java b/ProjectAirFighter/src/Forms/FormConstructor.java
index 975a148..4977bfe 100644
--- a/ProjectAirFighter/src/Forms/FormConstructor.java
+++ b/ProjectAirFighter/src/Forms/FormConstructor.java
@@ -26,10 +26,10 @@ public class FormConstructor extends JFrame {
JLabel secondEntityLabel = new JLabel();
JLabel thirdEntityLabel = new JLabel();
- JPanel paddlesInfoPanel = new JPanel();
- JLabel firstPaddlesLabel = new JLabel();
- JLabel secondPaddlesLabel = new JLabel();
- JLabel thirdPaddlesLabel = new JLabel();
+ JPanel engineInfoPanel = new JPanel();
+ JLabel firstEngineLabel = new JLabel();
+ JLabel secondEngineLabel = new JLabel();
+ JLabel thirdEngineLabel = new JLabel();
public void OpenFrame() {
@@ -51,23 +51,23 @@ public class FormConstructor extends JFrame {
entitiesInfoPanel.add(secondEntityLabel);
entitiesInfoPanel.add(thirdEntityLabel);
- firstPaddlesLabel.setText(constructor.getEngineString(0));
- secondPaddlesLabel.setText(constructor.getEngineString(1));
- thirdPaddlesLabel.setText(constructor.getEngineString(2));
+ firstEngineLabel.setText(constructor.getEngineString(0));
+ secondEngineLabel.setText(constructor.getEngineString(1));
+ thirdEngineLabel.setText(constructor.getEngineString(2));
- paddlesInfoPanel.setLayout(new BoxLayout(paddlesInfoPanel, BoxLayout.Y_AXIS));
- paddlesInfoPanel.setBorder(BorderFactory.createTitledBorder("Engine"));
- paddlesInfoPanel.setSize(500, 130);
- paddlesInfoPanel.setLocation(150, 150);
- paddlesInfoPanel.add(firstPaddlesLabel);
- paddlesInfoPanel.add(secondPaddlesLabel);
- paddlesInfoPanel.add(thirdPaddlesLabel);
+ engineInfoPanel.setLayout(new BoxLayout(engineInfoPanel, BoxLayout.Y_AXIS));
+ engineInfoPanel.setBorder(BorderFactory.createTitledBorder("Engine"));
+ engineInfoPanel.setSize(500, 130);
+ engineInfoPanel.setLocation(150, 150);
+ engineInfoPanel.add(firstEngineLabel);
+ engineInfoPanel.add(secondEngineLabel);
+ engineInfoPanel.add(thirdEngineLabel);
addButton.setBounds(0, jFrameConstructor.getHeight() - 105, 150, 50);
reCreateButton.setBounds(0, jFrameConstructor.getHeight() - 135, 150, 30);
- jFrameConstructor.add(paddlesInfoPanel);
+ jFrameConstructor.add(engineInfoPanel);
jFrameConstructor.add(entitiesInfoPanel);
jFrameConstructor.add(addButton);
jFrameConstructor.add(reCreateButton);
--
2.25.1
From 23058f6672f20ce5e7dcc7421fce15bf00d46185 Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sun, 16 Jun 2024 00:33:20 +0400
Subject: [PATCH 4/9] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../AbstractCompany.java | 6 +--
.../AirCraftAngar.java | 53 ++++++++-----------
.../CollectionGenericObjects/Constructor.java | 2 +-
.../src/Drawnings/DrawningAirCraft.java | 44 +++++++--------
.../src/Drawnings/DrawningAirFighter.java | 40 +++++++-------
.../src/Drawnings/DrawningConstructor.java | 2 +-
6 files changed, 70 insertions(+), 77 deletions(-)
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java b/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
index efd6ae5..c5eb4b3 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/AbstractCompany.java
@@ -6,13 +6,13 @@ import java.awt.*;
import java.util.Random;
public abstract class AbstractCompany {
- protected final int _placeSizeWidth = 210;
- protected final int _placeSizeHeight = 120;
+ protected final int _placeSizeWidth = 100;
+ protected final int _placeSizeHeight = 86;
protected final int _pictureWidth;
protected final int _pictureHeight;
protected ICollectionGenericObjects _collection = null;
public int getMaxCount() {
- return _pictureWidth * _pictureHeight / (_placeSizeWidth*_placeSizeHeight);
+ return _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
}
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) {
this._pictureWidth = picWidth;
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
index 0fed8a5..6fa3703 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
@@ -9,35 +9,31 @@ import java.util.List;
public class AirCraftAngar extends AbstractCompany {
private final List locCoord = new ArrayList<>();
private int numRows, numCols;
+
public AirCraftAngar(int picWidth, int picHeight, ICollectionGenericObjects collection) {
super(picWidth, picHeight, collection);
_collection.setMaxCount(30);
-
}
+
+ int pamat_i = 0;
+ int pamat_j = 0;
+
@Override
protected void drawBackground(Graphics g) {
Color backgroundColor = new Color(255, 255, 255);
g.setColor(backgroundColor);
g.fillRect(0, 0, _pictureWidth, _pictureHeight);
-
- g.setColor(new Color(165, 42, 42)); // Brown
- int offsetX = 10, offsetY = -5;
- int x = 1 + offsetX, y = _pictureHeight - _placeSizeHeight + offsetY;
- numRows = 0;
- while (y >= 0) {
- int numCols = 0;
- while (x + _placeSizeWidth <= _pictureWidth) {
- numCols++;
- g.drawLine(x, y, x + _placeSizeWidth / 2, y);
- g.drawLine(x, y, x, y + _placeSizeHeight + 4);
- locCoord.add(new Point(x, y));
- x += _placeSizeWidth + 2;
+ g.setColor(Color.black);
+ ((Graphics2D) g).setStroke(new BasicStroke(4));
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {
+ pamat_i = i;
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) {
+ pamat_j = j;
+ g.drawLine(i * _placeSizeWidth, j * _placeSizeHeight, (int) (_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j);
+ g.drawLine(i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth, _placeSizeHeight * (j + 1));
}
- numRows++;
- x = 1 + offsetX;
- y -= _placeSizeHeight + 5 + offsetY;
+ g.drawLine(i * _placeSizeWidth, _placeSizeHeight * (_pictureHeight / _placeSizeHeight), (int) (_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
}
-
}
@Override
@@ -45,18 +41,15 @@ public class AirCraftAngar extends AbstractCompany {
if (locCoord == null || _collection == null) {
return;
}
- int row = numRows - 1, col = numCols;
- for (int i=0;i< _collection.getCount(); i++, col--) {
- if (_collection.get(i) != null) {
- _collection.get(i).setPictureSize(_pictureWidth, _pictureHeight);
- _collection.get(i).setPosition((int)locCoord.get(row*numCols - col).getX() + 5,
- (int)locCoord.get(row*numCols - col).getY() + 9);
- if (col == 1) {
- col = numCols + 1;
- row--;
- }
- }
+ int currentIndex = -1;
+ for (int j = pamat_j; j >= 0; j--) {
+ for (int i = pamat_i; i >= 0; i--) {
+ currentIndex++;
+ if (_collection.get(currentIndex) == null) continue;
+ _collection.get(currentIndex).setPictureSize(_pictureWidth, _pictureHeight);
+ _collection.get(currentIndex).setPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
index a60ef3f..80ba521 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
@@ -21,7 +21,7 @@ public class Constructor {
public DrawningAirCraft getRandomAirCraft() {
Random rnd = new Random();
- int entityIndex = rnd.nextInt(0, 3);
+ int entityIndex = rnd.nextInt(0, 2);
int engineIndex = rnd.nextInt(0, 3);
T entity = entitiesList.get(entityIndex);
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
index 9f102ac..c74ecc2 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
@@ -1,7 +1,7 @@
package Drawnings;
-import Entities.EntityAirCraft;
-import MovementStrategy.MovementDirection;
+import Entities.*;
+import MovementStrategy.*;
import java.awt.*;
import java.util.Random;
@@ -79,7 +79,7 @@ public class DrawningAirCraft {
_startPosX = x;
_startPosY = y;
- if (_drawingAirCraftWidth + x > _pictureWidth || x < 0) {
+ if (x > _pictureWidth - _drawingAirCraftWidth) {
_startPosX = 0;
}
if (_drawingAirCraftHeight + y > _pictureHeight || y < 0) {
@@ -136,10 +136,10 @@ public class DrawningAirCraft {
Graphics2D g2d = (Graphics2D) g;
Point[] rtail = new Point[]{
+ new Point(_startPosX , _startPosY + 25),
+ new Point(_startPosX , _startPosY + 8),
+ new Point(_startPosX + 10, _startPosY + 17),
new Point(_startPosX + 10, _startPosY + 25),
- new Point(_startPosX + 10, _startPosY + 8),
- new Point(_startPosX + 20, _startPosY + 17),
- new Point(_startPosX + 20, _startPosY + 25),
};
Polygon rtailPolygon = new Polygon();
for (Point point : rtail)
@@ -149,10 +149,10 @@ public class DrawningAirCraft {
g2d.fillPolygon(rtailPolygon);
Point[] ltail = new Point[]{
+ new Point(_startPosX, _startPosY + 49),
+ new Point(_startPosX , _startPosY + 66),
+ new Point(_startPosX + 10, _startPosY + 57),
new Point(_startPosX + 10, _startPosY + 49),
- new Point(_startPosX + 10, _startPosY + 66),
- new Point(_startPosX + 20, _startPosY + 57),
- new Point(_startPosX + 20, _startPosY + 49),
};
Polygon ltailPolygon = new Polygon();
for (Point point : ltail)
@@ -162,10 +162,10 @@ public class DrawningAirCraft {
g2d.fillPolygon(ltailPolygon);
Point[] rwing = new Point[]{
- new Point(_startPosX + 45, _startPosY + 49),
- new Point(_startPosX + 45, _startPosY + 74),
- new Point(_startPosX + 37, _startPosY + 74),
- new Point(_startPosX + 30, _startPosY + 49),
+ new Point(_startPosX + 35, _startPosY + 49),
+ new Point(_startPosX + 35, _startPosY + 74),
+ new Point(_startPosX + 27, _startPosY + 74),
+ new Point(_startPosX + 20, _startPosY + 49),
};
Polygon rwingPolygon = new Polygon();
for (Point point : rwing)
@@ -175,10 +175,10 @@ public class DrawningAirCraft {
g2d.fillPolygon(rwingPolygon);
Point[] lwing = new Point[]{
- new Point(_startPosX + 45, _startPosY + 25),
- new Point(_startPosX + 45, _startPosY),
- new Point(_startPosX + 37, _startPosY),
- new Point(_startPosX + 30, _startPosY + 25),
+ new Point(_startPosX + 35, _startPosY + 25),
+ new Point(_startPosX + 35, _startPosY),
+ new Point(_startPosX + 27, _startPosY),
+ new Point(_startPosX + 20, _startPosY + 25),
};
Polygon lwingPolygon = new Polygon();
for (Point point : lwing)
@@ -187,13 +187,13 @@ public class DrawningAirCraft {
g2d.setColor(entityAirCraft.getBodyColor());
g2d.fillPolygon(lwingPolygon);
- g2d.drawRect(_startPosX + 10, _startPosY + 25, 50, 24);
- g2d.fillRect(_startPosX + 10, _startPosY + 25, 50, 24);
+ g2d.drawRect(_startPosX , _startPosY + 25, 50, 24);
+ g2d.fillRect(_startPosX , _startPosY + 25, 50, 24);
Point[] nose = new Point[]{
- new Point(_startPosX + 60, _startPosY + 25),
- new Point(_startPosX + 76, _startPosY + 37),
- new Point(_startPosX + 60, _startPosY + 49),
+ new Point(_startPosX + 50, _startPosY + 25),
+ new Point(_startPosX + 66, _startPosY + 37),
+ new Point(_startPosX + 50, _startPosY + 49),
};
Polygon nosePolygon = new Polygon();
for (Point point : nose)
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
index 9f44440..6f6b437 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
@@ -1,12 +1,12 @@
package Drawnings;
-import Entities.EntityAirFighter;
+import Entities.*;
import java.awt.*;
public class DrawningAirFighter extends DrawningAirCraft {
public DrawningAirFighter(int speed, float weight, Color bodyColor, int engineType, Color additionalColor, boolean pgo, boolean rockets) {
- super(speed, weight, bodyColor, engineType, 76, 80);
+ super(speed, weight, bodyColor, engineType, 66, 74);
entityAirCraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, pgo, rockets);
}
@@ -22,9 +22,9 @@ public class DrawningAirFighter extends DrawningAirCraft {
if (entityAirFighter.getPgo()) {
Point[] pgo1 = new Point[]{
- new Point(_startPosX + 50, _startPosY + 25),
- new Point(_startPosX + 50, _startPosY + 15),
- new Point(_startPosX + 55, _startPosY + 25),
+ new Point(_startPosX + 40, _startPosY + 25),
+ new Point(_startPosX + 40, _startPosY + 15),
+ new Point(_startPosX + 45, _startPosY + 25),
};
Polygon pgo1Polygon = new Polygon();
for (Point point : pgo1)
@@ -34,9 +34,9 @@ public class DrawningAirFighter extends DrawningAirCraft {
g2d.fillPolygon(pgo1Polygon);
Point[] pgo2 = new Point[]{
- new Point(_startPosX + 50, _startPosY + 49),
- new Point(_startPosX + 50, _startPosY + 59),
- new Point(_startPosX + 55, _startPosY + 49),
+ new Point(_startPosX + 40, _startPosY + 49),
+ new Point(_startPosX + 40, _startPosY + 59),
+ new Point(_startPosX + 45, _startPosY + 49),
};
Polygon pgo2Polygon = new Polygon();
for (Point point : pgo2)
@@ -48,10 +48,10 @@ public class DrawningAirFighter extends DrawningAirCraft {
if (entityAirFighter.getRockets()) {
Point[] rocket1 = new Point[]{
- new Point(_startPosX + 50, _startPosY + 71),
- new Point(_startPosX + 50, _startPosY + 74),
- new Point(_startPosX + 55, _startPosY + 69),
- new Point(_startPosX + 50, _startPosY + 64),
+ new Point(_startPosX + 40, _startPosY + 71),
+ new Point(_startPosX + 40, _startPosY + 74),
+ new Point(_startPosX + 45, _startPosY + 69),
+ new Point(_startPosX + 40, _startPosY + 64),
};
Polygon rocket1Polygon = new Polygon();
for (Point point : rocket1)
@@ -60,14 +60,14 @@ public class DrawningAirFighter extends DrawningAirCraft {
g2d.setColor(entityAirFighter.getAdditionalColor());
g2d.fillPolygon(rocket1Polygon);
- g.drawRect(_startPosX + 45, _startPosY + 67, 5, 4);
- g.fillRect(_startPosX + 45, _startPosY + 67, 5, 4);
+ g.drawRect(_startPosX + 35, _startPosY + 67, 5, 4);
+ g.fillRect(_startPosX + 35, _startPosY + 67, 5, 4);
Point[] rocket2 = new Point[]{
- new Point(_startPosX + 50, _startPosY + 7),
- new Point(_startPosX + 50, _startPosY + 10),
- new Point(_startPosX + 55, _startPosY + 5),
- new Point(_startPosX + 50, _startPosY),
+ new Point(_startPosX + 40, _startPosY + 7),
+ new Point(_startPosX + 40, _startPosY + 10),
+ new Point(_startPosX + 45, _startPosY + 5),
+ new Point(_startPosX + 40, _startPosY),
};
Polygon rocket2Polygon = new Polygon();
for (Point point : rocket2)
@@ -76,8 +76,8 @@ public class DrawningAirFighter extends DrawningAirCraft {
g2d.setColor(entityAirFighter.getAdditionalColor());
g2d.fillPolygon(rocket2Polygon);
- g.drawRect(_startPosX + 45, _startPosY + 3, 5, 4);
- g.fillRect(_startPosX + 45, _startPosY + 3, 5, 4);
+ g.drawRect(_startPosX + 35, _startPosY + 3, 5, 4);
+ g.fillRect(_startPosX + 35, _startPosY + 3, 5, 4);
}
}
}
\ No newline at end of file
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
index c6d4aed..c7ab6f5 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -70,7 +70,7 @@ public class DrawningConstructor extends JComponent {
super.paintComponent(g);
if (obj != null) {
obj.setPosition(10, 30);
- obj.setPictureSize(400, 300);
+ obj.setPictureSize(350, 300);
obj.drawAirCraft(g);
}
super.repaint();
--
2.25.1
From c432bf98b79b824b5070c0ab3c493145b68fae93 Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sun, 16 Jun 2024 13:43:13 +0400
Subject: [PATCH 5/9] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D0=B5=D1=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ProjectAirFighter/src/Drawnings/DrawningAirCraft.java | 2 +-
ProjectAirFighter/src/Drawnings/DrawningAirFighter.java | 4 ++--
ProjectAirFighter/src/Drawnings/DrawningConstructor.java | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
index c74ecc2..25af47d 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
@@ -79,7 +79,7 @@ public class DrawningAirCraft {
_startPosX = x;
_startPosY = y;
- if (x > _pictureWidth - _drawingAirCraftWidth) {
+ if (_drawingAirCraftWidth + x > _pictureWidth || x < 0) {
_startPosX = 0;
}
if (_drawingAirCraftHeight + y > _pictureHeight || y < 0) {
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
index 6f6b437..bf173d0 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
@@ -1,12 +1,12 @@
package Drawnings;
-import Entities.*;
+import Entities.EntityAirFighter;
import java.awt.*;
public class DrawningAirFighter extends DrawningAirCraft {
public DrawningAirFighter(int speed, float weight, Color bodyColor, int engineType, Color additionalColor, boolean pgo, boolean rockets) {
- super(speed, weight, bodyColor, engineType, 66, 74);
+ super(speed, weight, bodyColor, engineType, 76, 80);
entityAirCraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, pgo, rockets);
}
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
index c7ab6f5..9b04594 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -35,9 +35,9 @@ public class DrawningConstructor extends JComponent {
int engineCount = countengine[rnd.nextInt(countengine.length)];
_drawEngine.setNumber(engineCount);
- int typeBoat = rnd.nextInt(0,2);
+ int typeAir = rnd.nextInt(0,2);
- switch (typeBoat) {
+ switch (typeAir) {
case 0:
_entityAirCraft = new EntityAirCraft(rnd.nextInt(70 - 30) + 30, rnd.nextInt(500 - 100) + 100,
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
--
2.25.1
From 7924f3a68e3b431291321b40032cce60b1fed9ab Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sun, 16 Jun 2024 13:43:13 +0400
Subject: [PATCH 6/9] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D0=B5=D1=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/CollectionGenericObjects/Constructor.java | 2 +-
ProjectAirFighter/src/Drawnings/DrawningAirCraft.java | 2 +-
ProjectAirFighter/src/Drawnings/DrawningAirFighter.java | 4 ++--
ProjectAirFighter/src/Drawnings/DrawningConstructor.java | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
index 80ba521..a60ef3f 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
@@ -21,7 +21,7 @@ public class Constructor {
public DrawningAirCraft getRandomAirCraft() {
Random rnd = new Random();
- int entityIndex = rnd.nextInt(0, 2);
+ int entityIndex = rnd.nextInt(0, 3);
int engineIndex = rnd.nextInt(0, 3);
T entity = entitiesList.get(entityIndex);
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
index c74ecc2..25af47d 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
@@ -79,7 +79,7 @@ public class DrawningAirCraft {
_startPosX = x;
_startPosY = y;
- if (x > _pictureWidth - _drawingAirCraftWidth) {
+ if (_drawingAirCraftWidth + x > _pictureWidth || x < 0) {
_startPosX = 0;
}
if (_drawingAirCraftHeight + y > _pictureHeight || y < 0) {
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
index 6f6b437..bf173d0 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirFighter.java
@@ -1,12 +1,12 @@
package Drawnings;
-import Entities.*;
+import Entities.EntityAirFighter;
import java.awt.*;
public class DrawningAirFighter extends DrawningAirCraft {
public DrawningAirFighter(int speed, float weight, Color bodyColor, int engineType, Color additionalColor, boolean pgo, boolean rockets) {
- super(speed, weight, bodyColor, engineType, 66, 74);
+ super(speed, weight, bodyColor, engineType, 76, 80);
entityAirCraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, pgo, rockets);
}
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
index c7ab6f5..9b04594 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -35,9 +35,9 @@ public class DrawningConstructor extends JComponent {
int engineCount = countengine[rnd.nextInt(countengine.length)];
_drawEngine.setNumber(engineCount);
- int typeBoat = rnd.nextInt(0,2);
+ int typeAir = rnd.nextInt(0,2);
- switch (typeBoat) {
+ switch (typeAir) {
case 0:
_entityAirCraft = new EntityAirCraft(rnd.nextInt(70 - 30) + 30, rnd.nextInt(500 - 100) + 100,
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
--
2.25.1
From 916ebee85d3889428a756765c688ad14c092943d Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sun, 16 Jun 2024 13:48:57 +0400
Subject: [PATCH 7/9] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD?=
=?UTF-8?q?=D1=8F=D1=8F=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ProjectAirFighter/src/CollectionGenericObjects/Constructor.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
index a60ef3f..f8bbd80 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/Constructor.java
@@ -21,6 +21,7 @@ public class Constructor {
public DrawningAirCraft getRandomAirCraft() {
Random rnd = new Random();
+
int entityIndex = rnd.nextInt(0, 3);
int engineIndex = rnd.nextInt(0, 3);
--
2.25.1
From ab48eac4258c9fb0e35ddde7cd00f3183bd29b4b Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Sun, 16 Jun 2024 21:56:53 +0400
Subject: [PATCH 8/9] =?UTF-8?q?=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CollectionGenericObjects/AirCraftAngar.java | 6 ++----
.../src/Drawnings/DrawningAirCraft.java | 16 ++++++++--------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
index 6fa3703..159a01c 100644
--- a/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
+++ b/ProjectAirFighter/src/CollectionGenericObjects/AirCraftAngar.java
@@ -8,16 +8,14 @@ import java.util.List;
public class AirCraftAngar extends AbstractCompany {
private final List locCoord = new ArrayList<>();
- private int numRows, numCols;
+ int pamat_i = 0;
+ int pamat_j = 0;
public AirCraftAngar(int picWidth, int picHeight, ICollectionGenericObjects collection) {
super(picWidth, picHeight, collection);
_collection.setMaxCount(30);
}
- int pamat_i = 0;
- int pamat_j = 0;
-
@Override
protected void drawBackground(Graphics g) {
Color backgroundColor = new Color(255, 255, 255);
diff --git a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
index 25af47d..0fa1dca 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningAirCraft.java
@@ -136,8 +136,8 @@ public class DrawningAirCraft {
Graphics2D g2d = (Graphics2D) g;
Point[] rtail = new Point[]{
- new Point(_startPosX , _startPosY + 25),
- new Point(_startPosX , _startPosY + 8),
+ new Point(_startPosX+2, _startPosY + 25),
+ new Point(_startPosX+2, _startPosY + 8),
new Point(_startPosX + 10, _startPosY + 17),
new Point(_startPosX + 10, _startPosY + 25),
};
@@ -149,8 +149,8 @@ public class DrawningAirCraft {
g2d.fillPolygon(rtailPolygon);
Point[] ltail = new Point[]{
- new Point(_startPosX, _startPosY + 49),
- new Point(_startPosX , _startPosY + 66),
+ new Point(_startPosX+2, _startPosY + 49),
+ new Point(_startPosX+2, _startPosY + 66),
new Point(_startPosX + 10, _startPosY + 57),
new Point(_startPosX + 10, _startPosY + 49),
};
@@ -187,13 +187,13 @@ public class DrawningAirCraft {
g2d.setColor(entityAirCraft.getBodyColor());
g2d.fillPolygon(lwingPolygon);
- g2d.drawRect(_startPosX , _startPosY + 25, 50, 24);
- g2d.fillRect(_startPosX , _startPosY + 25, 50, 24);
+ g2d.drawRect(_startPosX , _startPosY + 24, 50, 25);
+ g2d.fillRect(_startPosX , _startPosY + 24, 50, 25);
Point[] nose = new Point[]{
- new Point(_startPosX + 50, _startPosY + 25),
+ new Point(_startPosX + 50, _startPosY + 26),
new Point(_startPosX + 66, _startPosY + 37),
- new Point(_startPosX + 50, _startPosY + 49),
+ new Point(_startPosX + 50, _startPosY + 48),
};
Polygon nosePolygon = new Polygon();
for (Point point : nose)
--
2.25.1
From b78de3d1460fff7eb7ba16512c223645968e3bd8 Mon Sep 17 00:00:00 2001
From: artur-kalimullin <144933634+artur-kalimullin@users.noreply.github.com>
Date: Mon, 17 Jun 2024 11:13:01 +0400
Subject: [PATCH 9/9] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE!?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ProjectAirFighter/src/Drawnings/DrawningConstructor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
index 9b04594..1879c59 100644
--- a/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
+++ b/ProjectAirFighter/src/Drawnings/DrawningConstructor.java
@@ -19,8 +19,8 @@ public class DrawningConstructor extends JComponent {
EntityAirCraft _entityAirCraft = null;
IDrawEngine _drawEngine = null;
Random rnd = new Random();
- int paddlesType = rnd.nextInt(3);
- switch (paddlesType) {
+ int Type = rnd.nextInt(3);
+ switch (Type) {
case 0:
_drawEngine = new DrawningEngine();
break;
--
2.25.1