From 78234afc84bd41cf101e9c89f693db4c8c03ae45 Mon Sep 17 00:00:00 2001 From: DavidMakarov Date: Fri, 15 Dec 2023 22:54:51 +0400 Subject: [PATCH] lab 3 --- .../AirplaneWithRadarForm.java | 50 +++++- .../FormAirplaneCollection.java | 146 ++++++++++++++++++ src/AirplaneWithRadar/FormWithArrays.java | 113 ++++++++++++++ .../Generics/AirplanesGenericCollection.java | 95 ++++++++++++ .../Generics/ArraysGeneric.java | 66 ++++++++ .../Generics/SetGeneric.java | 62 ++++++++ src/AirplaneWithRadar/PaintIlluminators.java | 4 +- .../PaintObjects/PaintAirplane.java | 27 +++- .../PaintObjects/PaintAirplaneWithRadar.java | 6 + .../PaintObjects/PaintIlluminators.java | 12 +- .../PaintRoundedRectIlluminator.java | 12 +- src/Main.java | 4 +- 12 files changed, 575 insertions(+), 22 deletions(-) create mode 100644 src/AirplaneWithRadar/FormAirplaneCollection.java create mode 100644 src/AirplaneWithRadar/FormWithArrays.java create mode 100644 src/AirplaneWithRadar/Generics/AirplanesGenericCollection.java create mode 100644 src/AirplaneWithRadar/Generics/ArraysGeneric.java create mode 100644 src/AirplaneWithRadar/Generics/SetGeneric.java diff --git a/src/AirplaneWithRadar/AirplaneWithRadarForm.java b/src/AirplaneWithRadar/AirplaneWithRadarForm.java index 9ad095a..69d5d4a 100644 --- a/src/AirplaneWithRadar/AirplaneWithRadarForm.java +++ b/src/AirplaneWithRadar/AirplaneWithRadarForm.java @@ -1,7 +1,7 @@ package AirplaneWithRadar; -import AirplaneWithRadar.MovementStrategy.Movement; import AirplaneWithRadar.MovementStrategy.*; +import AirplaneWithRadar.MovementStrategy.Movement; import AirplaneWithRadar.PaintObjects.PaintAirplane; import AirplaneWithRadar.PaintObjects.PaintAirplaneWithRadar; @@ -14,6 +14,8 @@ import java.util.Random; public class AirplaneWithRadarForm extends JFrame { private PaintAirplane PaintPlanes; private AbstractStrategy abstractStrategy; + public PaintAirplane SelectedAiplane; + public PaintAirplane GetSelectedAirplane() { return PaintPlanes; } private void Draw() { @@ -33,6 +35,8 @@ public class AirplaneWithRadarForm extends JFrame { public AirplaneWithRadarForm() { InitializeComponent(); + abstractStrategy = null; + SelectedAiplane = null; } private void InitializeComponent() @@ -46,6 +50,7 @@ public class AirplaneWithRadarForm extends JFrame { ButtonUp = new JButton(); MovementStrategyComboBox = new JComboBox(); ButtonPerformMove = new JButton(); + SelectAiplaneButton = new JButton(); AirplanePictureBox.setBounds(0, 0, 884, 461); // // ButtonCreateBomberBase @@ -124,6 +129,15 @@ public class AirplaneWithRadarForm extends JFrame { MovementStrategyComboBox.addItem("Перемещать в центр"); MovementStrategyComboBox.addItem("Перемещать вправо вниз"); // + // SelectBomberButton + // + SelectAiplaneButton.setBounds(354, 407, 159, 42); + SelectAiplaneButton.setName("SelectBomberButton"); + SelectAiplaneButton.setText("Выбрать бомбардировщик"); + SelectAiplaneButton.setBackground(new Color(225, 225, 225)); + SelectAiplaneButton.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + SelectAiplaneButton.setFocusable(false); + // // AirplaneWithRadarForm // setTitle("Самолет с радаром"); @@ -141,6 +155,7 @@ public class AirplaneWithRadarForm extends JFrame { add(ButtonPerformMove); add(MovementStrategyComboBox); add(AirplanePictureBox); + add(SelectAiplaneButton); } private JLabel AirplanePictureBox; private JButton ButtonCreateAirplane; @@ -151,6 +166,7 @@ public class AirplaneWithRadarForm extends JFrame { private JButton ButtonUp; private JButton ButtonPerformMove; private JComboBox MovementStrategyComboBox; + public JButton SelectAiplaneButton; private void ButtonMove_Click(ActionEvent e) { @@ -184,11 +200,28 @@ public class AirplaneWithRadarForm extends JFrame { { Random random = new Random(); + Color bodyColor = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)); + Color additColor = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)); + + JColorChooser BodyColorPicker = new JColorChooser(Color.BLACK); + if (JOptionPane.showConfirmDialog(null, BodyColorPicker, "Выберите цвет", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) + == JOptionPane.OK_OPTION) + { + bodyColor = BodyColorPicker.getColor(); + } + + JColorChooser AdditionalColorPicker = new JColorChooser(Color.BLACK); + if (JOptionPane.showConfirmDialog(null, AdditionalColorPicker, "Выберите цвет", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) + == JOptionPane.OK_OPTION) + { + additColor = AdditionalColorPicker.getColor(); + } + PaintPlanes = new PaintAirplaneWithRadar( random.nextInt(100, 300), random.nextInt(1000, 3000), - new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), - new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), + bodyColor, + additColor, true, true, AirplanePictureBox.getWidth(), @@ -203,10 +236,19 @@ public class AirplaneWithRadarForm extends JFrame { { Random random = new Random(); + Color bodyColor = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)); + + JColorChooser BodyColorPicker = new JColorChooser(Color.BLACK); + if (JOptionPane.showConfirmDialog(null, BodyColorPicker, "Выберите цвет", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) + == JOptionPane.OK_OPTION) + { + bodyColor = BodyColorPicker.getColor(); + } + PaintPlanes = new PaintAirplane( random.nextInt(100, 300), random.nextInt(1000, 3000), - new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), + bodyColor, AirplanePictureBox.getWidth(), AirplanePictureBox.getHeight() ); diff --git a/src/AirplaneWithRadar/FormAirplaneCollection.java b/src/AirplaneWithRadar/FormAirplaneCollection.java new file mode 100644 index 0000000..a2c4ba7 --- /dev/null +++ b/src/AirplaneWithRadar/FormAirplaneCollection.java @@ -0,0 +1,146 @@ +package AirplaneWithRadar; + +import AirplaneWithRadar.Generics.AirplanesGenericCollection; +import AirplaneWithRadar.MovementStrategy.PaintObjectAirplane; +import AirplaneWithRadar.PaintObjects.PaintAirplane; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +public class FormAirplaneCollection extends JFrame { + private final AirplanesGenericCollection aiplanes; + + public FormAirplaneCollection() + { + InitializeComponent(); + aiplanes = new AirplanesGenericCollection( + CollectionPictureBox.getWidth(), CollectionPictureBox.getHeight() + ); + } + + public void ButtonAddEntity_Click(ActionEvent e) + { + AirplaneWithRadarForm Form = new AirplaneWithRadarForm(); + + Form.SelectAiplaneButton.addActionListener(e2 -> { + if (aiplanes.Add(Form.GetSelectedAirplane()) != -1) + { + JOptionPane.showMessageDialog(null, "Объект добавлен"); + CollectionPictureBox.setIcon(new ImageIcon(aiplanes.ShowAirplanes())); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); + } + + Form.dispose(); + }); + } + + public void ButtonRemoveEntity_Click(ActionEvent e) + { + int Pos; + try + { + Pos = Integer.parseInt(NumberMaskedTextBox.getText()); + } + catch (Exception ex) + { + JOptionPane.showMessageDialog(null, "Некорректный ввод"); + return; + } + + if (aiplanes.Remove(Pos) == true) + { + JOptionPane.showMessageDialog(null, "Объект удален"); + CollectionPictureBox.setIcon(new ImageIcon(aiplanes.ShowAirplanes())); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось удалить объект"); + } + } + + public void ButtonRefreshCollection_Click(ActionEvent e) + { + CollectionPictureBox.setIcon(new ImageIcon(aiplanes.ShowAirplanes())); + } + + private void InitializeComponent() + { + CollectionPictureBox = new JLabel(); + ToolGroupBox = new JPanel(); + RefreshCollectionButton = new JButton(); + RemoveBomberButton = new JButton(); + NumberMaskedTextBox = new JTextField(); + AddBomberButton = new JButton(); + // + // CollectionPictureBox + // + CollectionPictureBox.setBounds(0, 0, 812, 603); + // + // ToolGroupBox + // + ToolGroupBox.add(RefreshCollectionButton); + ToolGroupBox.add(RemoveBomberButton); + ToolGroupBox.add(NumberMaskedTextBox); + ToolGroupBox.add(AddBomberButton); + ToolGroupBox.setBounds(818, 12, 210, 545); + ToolGroupBox.setName("ToolGroupBox"); + ToolGroupBox.setBorder(BorderFactory.createTitledBorder("Инструменты")); + ToolGroupBox.setLayout(null); + // + // RefreshCollectionButton + // + RefreshCollectionButton.setBounds(10, 190, 190, 30); + RefreshCollectionButton.setName("RefreshCollectionButton"); + RefreshCollectionButton.setText("Обновить коллекцию"); + RefreshCollectionButton.setBackground(new Color(225, 225, 225)); + RefreshCollectionButton.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + RefreshCollectionButton.setFocusable(false); + RefreshCollectionButton.addActionListener(e -> ButtonRefreshCollection_Click(e)); + // + // RemoveBomberButton + // + RemoveBomberButton.setBounds(10, 141, 190, 30); + RemoveBomberButton.setName("RemoveBomberButton"); + RemoveBomberButton.setText("Удалить бомбардировщик"); + RemoveBomberButton.setBackground(new Color(225, 225, 225)); + RemoveBomberButton.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + RemoveBomberButton.setFocusable(false); + RemoveBomberButton.addActionListener(e -> ButtonRemoveEntity_Click(e)); + // + // NumberMaskedTextBox + // + NumberMaskedTextBox.setBounds(10, 102, 190, 23); + NumberMaskedTextBox.setName("NumberMaskedTextBox"); + // + // AddBomberButton + // + AddBomberButton.setBounds(10, 32, 190, 43); + AddBomberButton.setName("AddBomberButton"); + AddBomberButton.setText("Добавить бомбардировщик"); + AddBomberButton.setBackground(new Color(225, 225, 225)); + AddBomberButton.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + AddBomberButton.setFocusable(false); + AddBomberButton.addActionListener(e -> ButtonAddEntity_Click(e)); + // + // FormEntityCollection + // + setTitle("Набор самолётов"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setSize(1050, 603); + setLayout(null); + setLocationRelativeTo(null); + setVisible(true); + add(ToolGroupBox); + add(CollectionPictureBox); + } + + private JLabel CollectionPictureBox; + private JPanel ToolGroupBox; + private JButton RefreshCollectionButton; + private JButton RemoveBomberButton; + private JTextField NumberMaskedTextBox; + private JButton AddBomberButton; +} diff --git a/src/AirplaneWithRadar/FormWithArrays.java b/src/AirplaneWithRadar/FormWithArrays.java new file mode 100644 index 0000000..713631d --- /dev/null +++ b/src/AirplaneWithRadar/FormWithArrays.java @@ -0,0 +1,113 @@ +package AirplaneWithRadar; + +import AirplaneWithRadar.Entities.AirplaneEntity; +import AirplaneWithRadar.Generics.ArraysGeneric; +import AirplaneWithRadar.PaintObjects.*; +import AirplaneWithRadar.PaintObjects.IPaintIlluminators; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.image.BufferedImage; +import java.util.Random; + +public class FormWithArrays extends JFrame { + private ArraysGeneric arrays; + + public FormWithArrays() + { + InitializeComponent(); + + Random random = new Random(); + int MaxCount = random.nextInt(2, 4); + + arrays = new ArraysGeneric<>(MaxCount, MaxCount, PictureBox.getWidth(), PictureBox.getHeight()); + + for (int i = 0; i < MaxCount; i++) + { + arrays.Add(new AirplaneEntity( + random.nextInt(100, 300), + random.nextInt(1000, 3000), + new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)) + )); + + IPaintIlluminators paintIllums = null; + + int paintIllumsVariant = random.nextInt(1, 4); + switch (paintIllumsVariant) { + case 1: + paintIllums = new PaintIlluminators(); + break; + + case 2: + paintIllums = new PaintRectangleIlluminators(); + break; + + case 3: + paintIllums = new PaintRoundedRectIlluminator(); + break; + + default: + break; + } + + paintIllums.setCount(random.nextInt(6, 35)); + arrays.Add(paintIllums); + } + } + + private void Draw(PaintAirplane PaintPlanes) + { + BufferedImage bmp = new BufferedImage( + PictureBox.getWidth(), + PictureBox.getHeight(), + BufferedImage.TYPE_INT_ARGB + ); + Graphics2D g = bmp.createGraphics(); + PaintPlanes.DrawTransport(g); + + PictureBox.setIcon(new ImageIcon(bmp)); + } + + private void ButtonCreate_Click(ActionEvent e) + { + PaintAirplane PaintPlanes = arrays.CreateObject(); + + PaintPlanes.SetPosition(100, 100); + Draw(PaintPlanes); + } + + private void InitializeComponent() + { + PictureBox = new JLabel(); + ButtonCreate = new JButton(); + // + // ButtonCreate + // + ButtonCreate.setName("ButtonCreate"); + ButtonCreate.setBounds(12, 419, 80, 30); + ButtonCreate.setText("Создать"); + ButtonCreate.setBackground(new Color(225, 225, 225)); + ButtonCreate.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + ButtonCreate.setFocusable(false); + ButtonCreate.addActionListener(e -> ButtonCreate_Click(e)); + // + // PictureBox + // + PictureBox.setBounds(0, 0, 884, 461); + // + // BomberForm + // + setDefaultCloseOperation(EXIT_ON_CLOSE); + setTitle("Усложнение"); + setSize(900, 500); + setLayout(null); + setLocationRelativeTo(null); + setVisible(true); + add(PictureBox); + add(ButtonCreate); + } + + private JButton ButtonCreate; + private JLabel PictureBox; +} diff --git a/src/AirplaneWithRadar/Generics/AirplanesGenericCollection.java b/src/AirplaneWithRadar/Generics/AirplanesGenericCollection.java new file mode 100644 index 0000000..4b79200 --- /dev/null +++ b/src/AirplaneWithRadar/Generics/AirplanesGenericCollection.java @@ -0,0 +1,95 @@ +package AirplaneWithRadar.Generics; + +import AirplaneWithRadar.PaintObjects.PaintAirplane; +import AirplaneWithRadar.MovementStrategy.IMoveableObject; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class AirplanesGenericCollection { + private int pictWidth; + private int pictHeight; + private final int placeSizeWidth = 200; + private final int placeSizeHeight = 70; + private SetGeneric collection; + + public AirplanesGenericCollection(int picWidth, int picHeight) + { + int width = picWidth / placeSizeWidth; + int height = picHeight / placeSizeHeight; + pictWidth = picWidth; + pictHeight = picHeight; + collection = new SetGeneric(width * height); + + } + + public int Add(T obj) + { + if (obj == null) + { + return -1; + } + return collection.Insert(obj); + } + public boolean Remove(int pos) + { + T obj = collection.Get(pos); + if (obj == null) + { + return false; + } + return collection.Remove(pos); + } + + public U GetU(int pos) + { + return (U)collection.Get(pos).GetMoveableObject(); + } + + public BufferedImage ShowAirplanes() + { + BufferedImage bmp = new BufferedImage(pictWidth, pictHeight, BufferedImage.TYPE_INT_ARGB); + Graphics2D gr = bmp.createGraphics(); + DrawBackground(gr); + DrawObjects(gr); + return bmp; + } + + private void DrawBackground(Graphics2D g) + { + g.setColor(Color.BLACK); + g.setStroke(new BasicStroke(3)); + for (int i = 0; i < pictWidth / placeSizeWidth; i++) + { + for (int j = 0; j < pictHeight / placeSizeHeight + 1; ++j) + { + g.drawLine(i * placeSizeWidth, j * placeSizeHeight, i * placeSizeWidth + placeSizeWidth / 2, j * placeSizeHeight); + } + g.drawLine(i * placeSizeWidth, 0, i * placeSizeWidth, pictHeight / placeSizeHeight * placeSizeHeight); + } + } + private void DrawObjects(Graphics g) + { + int width = pictWidth / placeSizeWidth; + int height = pictHeight / placeSizeHeight; + + int j = 3; + int k = 0; + + for (int i = 0; i < collection.Count(); i++) + { + PaintAirplane airplane = collection.Get(i); + if (j < 0) + { + j += 4; + k++; + } + if (airplane != null) + { + airplane.SetPosition(placeSizeWidth * j, placeSizeHeight * k); + airplane.DrawTransport(g); + } + j--; + } + } +} diff --git a/src/AirplaneWithRadar/Generics/ArraysGeneric.java b/src/AirplaneWithRadar/Generics/ArraysGeneric.java new file mode 100644 index 0000000..f85ef2e --- /dev/null +++ b/src/AirplaneWithRadar/Generics/ArraysGeneric.java @@ -0,0 +1,66 @@ +package AirplaneWithRadar.Generics; + +import AirplaneWithRadar.Entities.AirplaneEntity; +import AirplaneWithRadar.PaintObjects.IPaintIlluminators; +import AirplaneWithRadar.PaintObjects.PaintAirplane; + +import java.util.ArrayList; +import java.util.Random; +public class ArraysGeneric { + private ArrayList airplanes; + private ArrayList paintIllums; + + private int airplanesCount = 0; + private int paintIllumsCount = 0; + + private final int aiplanesMaxCount; + private final int paintIllumsMaxCount; + + private final int pictWidth; + private final int pictHeight; + + public ArraysGeneric(int AiplanesMaxCount, int PaintIllumsMaxCount, int Width, int Height) + { + aiplanesMaxCount = AiplanesMaxCount; + paintIllumsMaxCount = PaintIllumsMaxCount; + + airplanes = new ArrayList(AiplanesMaxCount); + paintIllums = new ArrayList(PaintIllumsMaxCount); + + pictWidth = Width; + pictHeight = Height; + } + public boolean Add(T Entity) + { + if (Entity == null || airplanesCount >= aiplanesMaxCount) + return false; + + airplanes.add(airplanesCount++, Entity); + return true; + } + + public boolean Add(U Renderer) + { + if (Renderer == null || paintIllumsCount >= paintIllumsMaxCount) + return false; + + paintIllums.add(paintIllumsCount++, Renderer); + return true; + } + + public PaintAirplane CreateObject() + { + if (airplanesCount == 0 || paintIllumsCount == 0) + return null; + + Random Random = new Random(); + + int airplaneIndex = Random.nextInt(airplanesCount); + int paintIllumsIndex = Random.nextInt(paintIllumsCount); + + T airplane = airplanes.get(airplaneIndex); + U paintIllums = this.paintIllums.get(paintIllumsIndex); + + return new PaintAirplane(airplane, paintIllums, pictWidth, pictHeight); + } +} diff --git a/src/AirplaneWithRadar/Generics/SetGeneric.java b/src/AirplaneWithRadar/Generics/SetGeneric.java new file mode 100644 index 0000000..d2499c2 --- /dev/null +++ b/src/AirplaneWithRadar/Generics/SetGeneric.java @@ -0,0 +1,62 @@ +package AirplaneWithRadar.Generics; + +public class SetGeneric { + private final T[] places; + + public int Count() { return places.length; } + + @SuppressWarnings("unchecked") + public SetGeneric(int Count) + { + places = (T[]) new Object[Count]; + } + + public int Insert(T Entity) + { + return Insert(Entity, 0); + } + + public int Insert(T Entity, int Pos) + { + if (Pos >= Count() || Pos < 0) + return -1; + + if (places[Pos] == null) + { + places[Pos] = Entity; + return Pos; + } + + int EmptyPos = -1; + + for (int i = Pos + 1; i < Count(); i++) + if (places[i] == null) + { + EmptyPos = i; + break; + } + + if (EmptyPos == -1) + return -1; + + places[EmptyPos] = Entity; + return EmptyPos; + } + + public boolean Remove(int Pos) + { + if (Pos >= Count()) + return false; + + places[Pos] = null; + return true; + } + + public T Get(int Pos) + { + if (Pos >= Count()) + return null; + + return places[Pos]; + } +} diff --git a/src/AirplaneWithRadar/PaintIlluminators.java b/src/AirplaneWithRadar/PaintIlluminators.java index 3b72be2..0d02aaa 100644 --- a/src/AirplaneWithRadar/PaintIlluminators.java +++ b/src/AirplaneWithRadar/PaintIlluminators.java @@ -1,9 +1,11 @@ package AirplaneWithRadar; +import AirplaneWithRadar.PaintObjects.IPaintIlluminators; + import java.awt.Graphics; import java.awt.Color; -public class PaintIlluminators { +public class PaintIlluminators implements IPaintIlluminators { private IlluminatorsCount count; public void setCount(int count) { if (count <= 10) diff --git a/src/AirplaneWithRadar/PaintObjects/PaintAirplane.java b/src/AirplaneWithRadar/PaintObjects/PaintAirplane.java index 54bebf8..1844246 100644 --- a/src/AirplaneWithRadar/PaintObjects/PaintAirplane.java +++ b/src/AirplaneWithRadar/PaintObjects/PaintAirplane.java @@ -1,7 +1,9 @@ package AirplaneWithRadar.PaintObjects; import AirplaneWithRadar.Entities.AirplaneEntity; +import AirplaneWithRadar.MovementStrategy.IMoveableObject; import AirplaneWithRadar.MovementStrategy.Movement; +import AirplaneWithRadar.MovementStrategy.PaintObjectAirplane; import java.awt.*; import java.util.Random; @@ -10,7 +12,7 @@ public class PaintAirplane { public AirplaneEntity getAirplaneEntity() { return airplaneEntity; } - + public IMoveableObject GetMoveableObject() {return new PaintObjectAirplane(this);} private void setAirplaneEntity(AirplaneEntity airplaneEntity) { this.airplaneEntity = airplaneEntity; } @@ -65,20 +67,24 @@ public class PaintAirplane { Random Random = new Random(); - int paintIlluminatorsVariant = Random.nextInt(1, 4); - switch (paintIlluminatorsVariant) { + + int EngineRendererVariant = Random.nextInt(1, 4); + switch (EngineRendererVariant) { case 1: paintIlluminators = new PaintIlluminators(); break; + case 2: paintIlluminators = new PaintRectangleIlluminators(); break; + case 3: paintIlluminators = new PaintRoundedRectIlluminator(); break; default: break; } + paintIlluminators.setCount(Random.nextInt(6, 35)); } @@ -97,6 +103,21 @@ public class PaintAirplane { Random rnd = new Random(); paintIlluminators.setCount(rnd.nextInt(6, 35)); } + + public PaintAirplane(AirplaneEntity airplane, IPaintIlluminators paintIllums, int Width, int Height) + { + if (Width < planeWidth || Height < planeHeight) + return; + + startPosX = 0; + startPosY = 0; + + pictWidth = Width; + pictHeight = Height; + + this.airplaneEntity = airplane; + this.paintIlluminators = paintIllums; + } public void SetPosition(int x, int y) { if (x + planeWidth < pictWidth && y + planeHeight < pictHeight) { startPosX = x; diff --git a/src/AirplaneWithRadar/PaintObjects/PaintAirplaneWithRadar.java b/src/AirplaneWithRadar/PaintObjects/PaintAirplaneWithRadar.java index 89e7a90..cbcbb91 100644 --- a/src/AirplaneWithRadar/PaintObjects/PaintAirplaneWithRadar.java +++ b/src/AirplaneWithRadar/PaintObjects/PaintAirplaneWithRadar.java @@ -36,4 +36,10 @@ public class PaintAirplaneWithRadar extends PaintAirplane { g.fillRoundRect(startPosX, startPosY + planeHeight - 2*planeHeight / 5, planeWidth / 5, planeHeight / 6, 5, 5); } } + private void DrawTriangle(Graphics g, int x1, int y1, int x2, int y2, int x3, int y3) + { + g.drawLine(x1, y1, x2, y2); + g.drawLine(x2, y2, x3, y3); + g.drawLine(x3, y3, x1, y1); + } } diff --git a/src/AirplaneWithRadar/PaintObjects/PaintIlluminators.java b/src/AirplaneWithRadar/PaintObjects/PaintIlluminators.java index 3035911..6feba70 100644 --- a/src/AirplaneWithRadar/PaintObjects/PaintIlluminators.java +++ b/src/AirplaneWithRadar/PaintObjects/PaintIlluminators.java @@ -22,8 +22,8 @@ public class PaintIlluminators implements IPaintIlluminators{ int x = startPosX; for (int i = 0; i < 10; i++) { - g.fillOval(x + 34, startPosY + 30, 7, 7); - x += 8; + g.fillOval(x + 34, startPosY + 30, 5, 5); + x += 7; } if (count == IlluminatorsCount.Ten) return; @@ -31,8 +31,8 @@ public class PaintIlluminators implements IPaintIlluminators{ x = startPosX; for (int i = 0; i < 10; i++) { - g.fillOval(x + 34, startPosY + 38, 7, 7); - x += 8; + g.fillOval(x + 34, startPosY + 38, 5, 5); + x += 7; } if (count == IlluminatorsCount.Twenty) return; @@ -40,8 +40,8 @@ public class PaintIlluminators implements IPaintIlluminators{ x = startPosX; for (int i = 0; i < 10; i++) { - g.fillOval(x + 34, startPosY + 46, 7, 7); - x += 8; + g.fillOval(x + 34, startPosY + 46, 5, 5); + x += 7; } } } diff --git a/src/AirplaneWithRadar/PaintObjects/PaintRoundedRectIlluminator.java b/src/AirplaneWithRadar/PaintObjects/PaintRoundedRectIlluminator.java index d91deec..18dbacc 100644 --- a/src/AirplaneWithRadar/PaintObjects/PaintRoundedRectIlluminator.java +++ b/src/AirplaneWithRadar/PaintObjects/PaintRoundedRectIlluminator.java @@ -21,8 +21,8 @@ public class PaintRoundedRectIlluminator implements IPaintIlluminators { int x = startPosX; for (int i = 0; i < 10; i++) { - g.fillRoundRect(x + 34, startPosY + 30, 6, 6,2,2); - x += 8; + g.fillRoundRect(x + 34, startPosY + 30, 5, 5,3,3); + x += 7; } if (count == IlluminatorsCount.Ten) return; @@ -30,8 +30,8 @@ public class PaintRoundedRectIlluminator implements IPaintIlluminators { x = startPosX; for (int i = 0; i < 10; i++) { - g.fillRoundRect(x + 34, startPosY + 38, 6, 6,2,2); - x += 8; + g.fillRoundRect(x + 34, startPosY + 38, 5, 5,3,3); + x += 7; } if (count == IlluminatorsCount.Twenty) return; @@ -39,8 +39,8 @@ public class PaintRoundedRectIlluminator implements IPaintIlluminators { x = startPosX; for (int i = 0; i < 10; i++) { - g.fillRoundRect(x + 34, startPosY + 46, 6, 6,2,2); - x += 8; + g.fillRoundRect(x + 34, startPosY + 46, 5, 5,3,3); + x += 7; } } } diff --git a/src/Main.java b/src/Main.java index 87f89d9..94d9664 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,7 +1,7 @@ -import AirplaneWithRadar.AirplaneWithRadarForm; +import AirplaneWithRadar.FormWithArrays; public class Main { public static void main(String[] args) { - new AirplaneWithRadarForm(); + new FormWithArrays(); } } \ No newline at end of file