From 4937e3672fe574e78ea051cf7ac0e7a2bee629b4 Mon Sep 17 00:00:00 2001 From: ilyaryabovv Date: Sun, 3 Mar 2024 21:47:04 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=BE,?= =?UTF-8?q?=20=D0=BD=D0=BE=20=D0=BD=D0=B5=20=D0=B4=D0=BE=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=86=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/.idea/uiDesigner.xml | 124 +++++++++ .../src/CanvasStormtrooper.java | 16 ++ ProjectStormtrooper/src/DirectionType.java | 10 + ProjectStormtrooper/src/DrawingEngines.java | 21 ++ .../src/DrawingStormtrooper.java | 249 ++++++++++++++++++ .../src/EntityStormtrooper.java | 42 +++ ProjectStormtrooper/src/FormStormtrooper.java | 125 +++++++++ ProjectStormtrooper/src/Main.java | 5 +- ProjectStormtrooper/src/NumberOfEngines.java | 28 ++ 9 files changed, 619 insertions(+), 1 deletion(-) create mode 100644 ProjectStormtrooper/.idea/uiDesigner.xml create mode 100644 ProjectStormtrooper/src/CanvasStormtrooper.java create mode 100644 ProjectStormtrooper/src/DirectionType.java create mode 100644 ProjectStormtrooper/src/DrawingEngines.java create mode 100644 ProjectStormtrooper/src/DrawingStormtrooper.java create mode 100644 ProjectStormtrooper/src/EntityStormtrooper.java create mode 100644 ProjectStormtrooper/src/FormStormtrooper.java create mode 100644 ProjectStormtrooper/src/NumberOfEngines.java diff --git a/ProjectStormtrooper/.idea/uiDesigner.xml b/ProjectStormtrooper/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/ProjectStormtrooper/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ProjectStormtrooper/src/CanvasStormtrooper.java b/ProjectStormtrooper/src/CanvasStormtrooper.java new file mode 100644 index 0000000..d7254ab --- /dev/null +++ b/ProjectStormtrooper/src/CanvasStormtrooper.java @@ -0,0 +1,16 @@ +import javax.swing.*; +import java.awt.*; + +public class CanvasStormtrooper extends JComponent { + public DrawingStormtrooper _drawingStormtrooper; + public CanvasStormtrooper(){} + public void paintComponent(Graphics g) { + if (_drawingStormtrooper == null) { + return; + } + super.paintComponents(g); + Graphics2D g2d = (Graphics2D) g; + _drawingStormtrooper.DrawTransport(g2d); + super.repaint(); + } +} diff --git a/ProjectStormtrooper/src/DirectionType.java b/ProjectStormtrooper/src/DirectionType.java new file mode 100644 index 0000000..8f8a5fe --- /dev/null +++ b/ProjectStormtrooper/src/DirectionType.java @@ -0,0 +1,10 @@ +public enum DirectionType { + ///Вверх + Up, + ///Вниз + Down, + ///Влево + Left, + ///Вправо + Right +} diff --git a/ProjectStormtrooper/src/DrawingEngines.java b/ProjectStormtrooper/src/DrawingEngines.java new file mode 100644 index 0000000..ff2e828 --- /dev/null +++ b/ProjectStormtrooper/src/DrawingEngines.java @@ -0,0 +1,21 @@ +import java.awt.*; + +public class DrawingEngines { + private NumberOfEngines numberOfEngines; + + public NumberOfEngines getNumberOfEngines() { + return numberOfEngines; + } + DrawingEngines (int a){ + setAmountOfEngines(a); + } + public void setAmountOfEngines(int amount){ + if(NumberOfEngines.contains(amount)) { + numberOfEngines = NumberOfEngines.getNumber(amount); + } + } + public void DrawDecks(Graphics g, int x, int y, int width, int height, Color bodyColor) { + g.setColor(bodyColor); + g.fillRect(x, y, width, height); + } +} diff --git a/ProjectStormtrooper/src/DrawingStormtrooper.java b/ProjectStormtrooper/src/DrawingStormtrooper.java new file mode 100644 index 0000000..fcb9248 --- /dev/null +++ b/ProjectStormtrooper/src/DrawingStormtrooper.java @@ -0,0 +1,249 @@ +import java.awt.*; +import java.util.Random; + +public class DrawingStormtrooper { + public EntityStormtrooper EntityStormtrooper; + public DrawingEngines drawingEngines =null; + /// + /// Ширина окна + /// + private Integer _pictureWidth; + + /// + /// Высота окна + /// + private Integer _pictureHeight; + + /// + /// Левая координата прорисовки бомбардировщика + /// + private Integer _startPosX; + + /// + /// Верхняя кооридната прорисовки бомбардировщика + /// + private Integer _startPosY; + + /// + /// Ширина прорисовки бомбардировщика + /// + private final Integer _drawningStormtrooperWidth = 140; + + /// + /// Высота прорисовки бомбардировщика + /// + private final Integer _drawningStormtrooperHeight = 135; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия двигателей + /// Признак наличия бомб + /// Признак наличия ракет + public void Init(int speed, float weight, Color bodyColor, Color additionalColor,boolean rockets, boolean bombs, boolean engines) + { + EntityStormtrooper = new EntityStormtrooper(); + EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rockets,bombs ,engines); + if(engines==true){ + drawingEngines = new DrawingEngines((int)((Math.random()*3)+1)*2); + } + _startPosX=null; + _startPosY=null; + _pictureWidth = null; + _pictureHeight = null; + + } + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + public boolean SetPictureSize(int width, int height) + { + // TODO проверка, что объект "влезает" в размеры поля + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + if (width < _drawningStormtrooperWidth || height < _drawningStormtrooperHeight) return false; + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX !=null || _startPosY !=null) + { + if (_startPosX + _drawningStormtrooperWidth > _pictureWidth) + { + _startPosX = -_drawningStormtrooperWidth + _pictureWidth; + } + else if (_startPosX < 0) + { + _startPosX = 0; + } + if (_startPosY + _drawningStormtrooperHeight > _pictureHeight) + { + _startPosY = -_drawningStormtrooperHeight + _pictureHeight; + } + else if (_startPosY < 0) + { + _startPosY = 0; + } + } + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!(_pictureHeight != null && _pictureWidth != null)) return; + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + // то надо изменить координаты, чтобы он оставался в этих границах + if (x + _drawningStormtrooperWidth > _pictureWidth) + { + _startPosX = x - (x + _drawningStormtrooperWidth - _pictureWidth); + } + else if (x < 0) + { + _startPosX = 0; + } + else + { + _startPosX = x; + } + if (y + _drawningStormtrooperHeight > _pictureHeight) + { + _startPosY = y - (y + _drawningStormtrooperHeight - _pictureHeight); + } + else if (y < 0) + { + _startPosY = 0; + } + else + { + _startPosY = y; + } + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно + public boolean MoveTransport(DirectionType direction) + { + if (EntityStormtrooper == null || _startPosX==null || _startPosY==null) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityStormtrooper.Step > 0) + { + _startPosX -= (int)EntityStormtrooper.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY - EntityStormtrooper.Step > 0) + { + _startPosY -= (int)EntityStormtrooper.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + if (_startPosX + _drawningStormtrooperWidth + EntityStormtrooper.Step < _pictureWidth) + { + _startPosX += (int)EntityStormtrooper.Step; + }; + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + if (_startPosY + _drawningStormtrooperHeight + EntityStormtrooper.Step < _pictureHeight) + { + _startPosY += (int)EntityStormtrooper.Step; + } + return true; + default: + return false; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityStormtrooper == null || _startPosX==null || _startPosY==null) + { + return; + } + g.setColor(Color.black); + //Brush bodyColorBrush = new SolidBrush(EntityStormtrooper.BodyColor); + //Brush additionalBrush = new SolidBrush(EntityStormtrooper.AdditionalColor); + //Тело бомбардировщика + g.drawRect(_startPosX + 20, _startPosY + 60, 120, 20); + //Задние крылья бомбардировщика + g.drawLine(_startPosX+ 140, _startPosY+ 30, _startPosX+ 140, _startPosY+ 110); + g.drawLine(_startPosX+ 120, _startPosY+ 90, _startPosX+ 120, _startPosY+ 80); + g.drawLine(_startPosX+ 140, _startPosY+ 110, _startPosX + 120, _startPosY + 90); + g.drawLine(_startPosX+ 140, _startPosY+ 30, _startPosX+ 120, _startPosY+ 50); + g.drawLine(_startPosX+ 120, _startPosY+ 50, _startPosX+ 120, _startPosY+ 60); + //Крылья бомбардировщика + g.drawLine(_startPosX+ 50, _startPosY, _startPosX + 50, _startPosY + 60); + g.drawLine(_startPosX+ 50, _startPosY + 80, _startPosX + 50, _startPosY + 135); + g.drawLine(_startPosX+ 50, _startPosY + 135, _startPosX + 60, _startPosY + 135); + g.drawLine(_startPosX+ 60, _startPosY + 135, _startPosX + 65, _startPosY + 80); + g.drawLine(_startPosX+ 50, _startPosY, _startPosX + 60, _startPosY); + g.drawLine(_startPosX+ 60, _startPosY, _startPosX + 65, _startPosY + 60); + ///Нос бомбардировщика + Point[] Nose = new Point[3]; + int[] arrX = {_startPosX + 20, _startPosX,_startPosX+20}; + int[] arrY = {_startPosY + 80,_startPosY + 70,_startPosY + 60}; + Polygon poly = new Polygon(arrX,arrY,3); + g.fillPolygon(poly); + //Ракеты бомбардировщика + if (EntityStormtrooper.getRockets()) + { + g.setColor(EntityStormtrooper.getAdditionalColor()); + g.fillRect( _startPosX + 35, _startPosY + 20, 15, 5); + g.fillRect( _startPosX + 35, _startPosY + 110, 15, 5); + + } + //Бомбы бомбардировщика + if (EntityStormtrooper.getBombs()) + { + g.setColor(EntityStormtrooper.getAdditionalColor()); + g.fillRect(_startPosX + 40, _startPosY + 40, 10, 10); + g.fillRect(_startPosX + 40, _startPosY + 90, 10, 10); + } + if(EntityStormtrooper.getEngines() && drawingEngines!=null){ + switch(drawingEngines.getNumberOfEngines()){ + case TWO: + drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 50, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 81, 10, 10,EntityStormtrooper.getBodyColor()); + break; + case FOUR: + drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 10, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 101, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 30, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 121, 10, 10,EntityStormtrooper.getBodyColor()); + break; + case SIX: + drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 10, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 30, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 50, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 81, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 101, 10, 10,EntityStormtrooper.getBodyColor()); + drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 121, 10, 10,EntityStormtrooper.getBodyColor()); + break; + } + } + } +} diff --git a/ProjectStormtrooper/src/EntityStormtrooper.java b/ProjectStormtrooper/src/EntityStormtrooper.java new file mode 100644 index 0000000..b314e74 --- /dev/null +++ b/ProjectStormtrooper/src/EntityStormtrooper.java @@ -0,0 +1,42 @@ +import java.awt.*; +public class EntityStormtrooper { + private int Speed; + public int getSpeed() { + return Speed; + } + private float Weight; + public float getWeight() { + return Weight; + } + private Color BodyColor; + public Color getBodyColor() { + return BodyColor; + } + + private Color AdditionalColor; + public Color getAdditionalColor() { + return AdditionalColor; + } + private boolean Rockets; + public boolean getRockets() { + return Rockets; + } + private boolean Bombs; + public boolean getBombs() { + return Bombs; + } + private boolean Engines; + public boolean getEngines() {return Engines;} + public float Step; + public void Init(int speed, float weight, Color bodyColor, Color additionalColor, boolean rockets, boolean bombs, boolean engines) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Rockets = rockets; + Bombs = bombs; + Engines = engines; + Step = Speed * 100 / Weight; + } +} diff --git a/ProjectStormtrooper/src/FormStormtrooper.java b/ProjectStormtrooper/src/FormStormtrooper.java new file mode 100644 index 0000000..e0ca133 --- /dev/null +++ b/ProjectStormtrooper/src/FormStormtrooper.java @@ -0,0 +1,125 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.util.Random; + +public class FormStormtrooper extends JFrame { + private String title; + private Dimension dimension; + private int Width; + private int Height; + private CanvasStormtrooper canvasStormtrooper = new CanvasStormtrooper(); + private JButton CreateButton = new JButton("Создать");; + private JButton UpButton = new JButton(); + private JButton DownButton = new JButton();; + private JButton LeftButton = new JButton();; + private JButton RightButton = new JButton(); + public FormStormtrooper(String title, Dimension dimension) { + this.title = title; + this.dimension = dimension; + } + public void Init() { + setTitle(title); + setMinimumSize(dimension); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Width = getWidth() - 15; + Height = getHeight() - 35; + + CreateButton.setName("createButton"); + Icon iconUp = new ImageIcon("src\\Resources\\arrowUp.png"); + UpButton.setIcon(iconUp); + UpButton.setName("UP"); + DownButton.setName("DOWN"); + Icon iconDown = new ImageIcon("src\\Resources\\arrowDown.png"); + DownButton.setIcon(iconDown); + LeftButton.setName("LEFT"); + Icon iconLeft = new ImageIcon("src\\Resources\\arrowLeft.png"); + LeftButton.setIcon(iconLeft); + RightButton.setName("RIGHT"); + Icon iconRight = new ImageIcon("arrowRight.png"); + RightButton.setIcon(iconRight); + + CreateButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int StartPositionX = (int)(Math.random() * 90 + 10); + int StartPositionY = (int)(Math.random() * 90 + 10); + int speed = (int)(Math.random() * 300 + 100); + float weight = (float) (Math.random() * 3000 + 1000); + Color bodyColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); + Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0));; + boolean rockets = new Random().nextBoolean(); + boolean boombs = new Random().nextBoolean();; + boolean engines = new Random().nextBoolean();; + canvasStormtrooper._drawingStormtrooper = new DrawingStormtrooper(); + canvasStormtrooper._drawingStormtrooper.Init(speed, weight, bodyColor, additionalColor,rockets, boombs, engines); + canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); + canvasStormtrooper._drawingStormtrooper.SetPosition( StartPositionX, StartPositionY); + canvasStormtrooper.repaint(); + } + }); + + ActionListener actionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + if (canvasStormtrooper._drawingStormtrooper == null) return; + boolean result = false; + switch ((((JButton)(event.getSource())).getName())) { + case "UP": + result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Up); + break; + case "DOWN": + result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Down); + break; + case "LEFT": + result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Left); + break; + case "RIGHT": + result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Right); + break; + } + if (result) { + canvasStormtrooper.repaint(); + } + } + }; + UpButton.addActionListener(actionListener); + DownButton.addActionListener(actionListener); + LeftButton.addActionListener(actionListener); + RightButton.addActionListener(actionListener); + + setSize(dimension.width,dimension.height); + setLayout(null); + canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); + CreateButton.setBounds(10, getHeight() - 90, 100, 40); + UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50); + DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50); + RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50); + LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50); + add(CreateButton); + add(UpButton); + add(DownButton); + add(RightButton); + add(LeftButton); + add(canvasStormtrooper); + setVisible(true); + //обработка события изменения размеров окна + addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + Width = getWidth() - 15; + Height = getHeight() - 35; + if (canvasStormtrooper._drawingStormtrooper != null) + canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); + canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); + CreateButton.setBounds(10, getHeight() - 90, 100, 40); + UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50); + DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50); + RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50); + LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50); + } + }); + } +} diff --git a/ProjectStormtrooper/src/Main.java b/ProjectStormtrooper/src/Main.java index 3e59c38..b4b6838 100644 --- a/ProjectStormtrooper/src/Main.java +++ b/ProjectStormtrooper/src/Main.java @@ -1,5 +1,8 @@ +import java.awt.*; + public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + FormStormtrooper form = new FormStormtrooper("Бомбардировщик", new Dimension(800,800)); + form.Init(); } } \ No newline at end of file diff --git a/ProjectStormtrooper/src/NumberOfEngines.java b/ProjectStormtrooper/src/NumberOfEngines.java new file mode 100644 index 0000000..1d0775e --- /dev/null +++ b/ProjectStormtrooper/src/NumberOfEngines.java @@ -0,0 +1,28 @@ +public enum NumberOfEngines { + TWO(2), + FOUR(4), + SIX(6); + + private final int value; + NumberOfEngines(int value){ + this.value=value; + } + public static NumberOfEngines getNumber(int amount){ + NumberOfEngines [] num = NumberOfEngines.values(); + for(int i =0 ; i Date: Thu, 7 Mar 2024 17:47:15 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/Resources/arrowDown.jpg | Bin 0 -> 857 bytes ProjectStormtrooper/Resources/arrowLeft.jpg | Bin 0 -> 800 bytes ProjectStormtrooper/Resources/arrowRight.jpg | Bin 0 -> 786 bytes ProjectStormtrooper/Resources/arrowUp.jpg | Bin 0 -> 453 bytes ProjectStormtrooper/src/DrawingEngines.java | 36 +++++-- .../src/DrawingStormtrooper.java | 27 +----- .../src/EntityStormtrooper.java | 1 - ProjectStormtrooper/src/FormStormtrooper.java | 89 ++++++++---------- 8 files changed, 72 insertions(+), 81 deletions(-) create mode 100644 ProjectStormtrooper/Resources/arrowDown.jpg create mode 100644 ProjectStormtrooper/Resources/arrowLeft.jpg create mode 100644 ProjectStormtrooper/Resources/arrowRight.jpg create mode 100644 ProjectStormtrooper/Resources/arrowUp.jpg diff --git a/ProjectStormtrooper/Resources/arrowDown.jpg b/ProjectStormtrooper/Resources/arrowDown.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6d11c1f6d11849107b51f3999c0134907adc1bc5 GIT binary patch literal 857 zcmeAS@N?(olHy`uVBq!ia0vp^ZXnFT1|$ph9<=}|#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DinK$vl=HlH*D1JgTC7srr_xVLxq`h7|eIq>nYcD!iB9S#k( zxW-+Us}v6wu*PsSE@=L!wu8l7&8Ndky4T9WXadKPshuALFHUzpXT9f!a&G0XEfYR_ z&pYul;L`r2ZdJB@%N_oFXy4amDb%KzD1l5Y{KJ%QH1ojY$I2~-6K_3Q_pyS<-QC?p zvn4TPRoH5YsMlFrqrSX(rBSbWG|8}PNx!uH+)vi%hM<{=k9+E{M4My(m(Jslzj(-g zyZ80>ZRsmnrqShMANw90KFk~wAAecQ_T2gNiP_oNW%uu_id)aVG>B8ElO=bi@$SIv zM=xK#JZ}4_H2QDd{Jw9?A9S@ zJ@b>jdfxz^FTDNs(i8nghlG_HCkiE|crAVK_;IsZ zeTUoP4`08!PA>Ltbv&6;^zH7=8#fl{-n)7Ke*3`$hs#CN_&%S1{(SlJLOwpe2VcKV zUG`LyyLnGnaYY4(zP`T6%7rF8hb#^zOi=qS+U;6VSGUY_;mh~z;lSvy(cQ7@)Keqd z*;VUW9VdDm`O*-w#%rn5`A2-=hZnqjdHKtMX_4aM;#MChbdEhxKo^{VLGv$eMlDQs@ux{Iro>8&gO+Qbk2=hN8tX2{CRUzYn4SSR~= z_Sv((x2L~RS645nulJv97j;;nX0o{qU*@m7FJEfjxqJ8GlIh;s{cc5kJ~TJQ8<-s!JYD@<);T3K0RWP0k$?aI literal 0 HcmV?d00001 diff --git a/ProjectStormtrooper/Resources/arrowLeft.jpg b/ProjectStormtrooper/Resources/arrowLeft.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c49840c483399732cc2c44c6d1c778b40319d929 GIT binary patch literal 800 zcmV+*1K<3KP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0<}p*K~#8N?cCXp zDM1{^@v`qra4Q~!Hy~n(i1%>o%1d}CFTsTy#J(@*_?iDnPDVG4u2$9Rn^gFBGMdlO zGwB%|e=afAO-{O0{Yt^;q+oPXFght1ojwZF@Ap}^+oegYJ_fT|tym_LVVzEgwuse7 zV1N=1hp*S8(dhM3v@D1DA4TLWg^>jXSq8J&Y@|U!mcVScTNVrkX_6!EFhB_e0yN1J zSD4*yCnXBv1_Kno-%pc#aez&AZ)h({#VLVNRzLbGzL%i62gNq|<4d^n2^2 zbUvS@LP19F@5?Yiak*SH*{_#i?2dw-hQTq#?kMOf7#WW#uVxqqKfJ!-nes2gFiz)7 zha+h-^k^Lp2VMJ~9>RPh3c3sPttdzr=9^KFCd{{^pc@#4^3x3rP64Pc;k3i=>h(HK zMc8r;1_OGO_tS(ymuHUV4a>gXhC$V8RrAJWUZ%jHN~NN?16h}8Fvw0grote*;Fu1B z?0~}s29?WY%^k|JxWS-Osie7685UOG5ZJ%S}vE@%i(Z%y%epFe@qI1M0~HL`urH3KK4=)Jq4qag3(FA e=%ipYW9%>W$5}MsV;s literal 0 HcmV?d00001 diff --git a/ProjectStormtrooper/Resources/arrowRight.jpg b/ProjectStormtrooper/Resources/arrowRight.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9ec90718323e9658ad1a9ab5ca1f38a4c173a894 GIT binary patch literal 786 zcmV+t1MU2YP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0;fqtK~#8N?VL%D z;xH73O)<|i3l>}mgcyW411Dg`io>wr8Z5a48(4vuXXvUQyfskUh+by-;hmc}AoeuMOJe0i$A;skL z`NuXEi#@jQK{oMbXdnLS7$2CUa>TjfY220%_K zm7>gAq!I&Gs})P9)0A0HMHT);X)%a)yG>R8 zi}GR+&w38mw8LyRW5r^TGH3E#gY+|aX7H?UC@)6qgi%_||3(pI#k?9?l@#+z3Q$fA zj})MknEU-st=A|c=61X3TGyw9nCtb*K0fr7>Uc5eDSEGL0!NF16umv=FOC&sL<-<~ zCC*WqFe(LbU)1mQdMp}^TE1dC91gSLaQIk6@Eb0d3-kGWloX2cLW;o+ zTi{(%fRK+#8IQ-TP$;lcsYHA1$9;Z`22y=p+lebi16Pa&t{4qmF;8La6K#UdHQy}V Qr~m)}07*qoM6N<$f{Lb9A^-pY literal 0 HcmV?d00001 diff --git a/ProjectStormtrooper/Resources/arrowUp.jpg b/ProjectStormtrooper/Resources/arrowUp.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2eaea0f73f4227245e6e9b009c4242b57ffddc17 GIT binary patch literal 453 zcmeAS@N?(olHy`uVBq!ia0vp^Zb0nL!3HFE6&Wf5DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5M?jcysy3fAP(zfbi(^Pd+}k_Rd50VXSOaJOU4N6&HB-}T zhe3Z`kMGo!kCu1a1>?njUtiq&uk`oNCH9QUOm16v&g^@C|Gbti<7ep<(K$sk(gn01 zOgXfNX~i+k=FG@FLd#i}r9ae~Q!-_cmt5yI2 literal 0 HcmV?d00001 diff --git a/ProjectStormtrooper/src/DrawingEngines.java b/ProjectStormtrooper/src/DrawingEngines.java index ff2e828..5e0a692 100644 --- a/ProjectStormtrooper/src/DrawingEngines.java +++ b/ProjectStormtrooper/src/DrawingEngines.java @@ -2,20 +2,44 @@ import java.awt.*; public class DrawingEngines { private NumberOfEngines numberOfEngines; - public NumberOfEngines getNumberOfEngines() { return numberOfEngines; } - DrawingEngines (int a){ - setAmountOfEngines(a); - } public void setAmountOfEngines(int amount){ if(NumberOfEngines.contains(amount)) { numberOfEngines = NumberOfEngines.getNumber(amount); } } - public void DrawDecks(Graphics g, int x, int y, int width, int height, Color bodyColor) { + public void DrawEngines(Graphics g, int x, int y, Color bodyColor) { g.setColor(bodyColor); - g.fillRect(x, y, width, height); + g.fillRect(x, y, 10, 10); + } + + private void drawTwoEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 65, y + 50, bodyColor); + DrawEngines(g,x + 65, y + 81,bodyColor); + } + private void drawFourEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 62, y + 10,bodyColor); + DrawEngines(g,x + 64, y + 101,bodyColor); + DrawEngines(g,x + 64, y + 30,bodyColor); + DrawEngines(g,x + 62, y + 121,bodyColor); + } + private void drawSixEngines(Graphics g, int x, int y, Color bodyColor){ + drawFourEngines(g,x,y,bodyColor); + drawTwoEngines(g,x,y,bodyColor); + } + public void SwitchDrawEngines(Graphics g, int x, int y, Color bodyColor){ + switch(getNumberOfEngines()){ + case TWO: + drawTwoEngines(g,x,y,bodyColor); + break; + case FOUR: + drawFourEngines(g,x,y,bodyColor); + break; + case SIX: + drawSixEngines(g,x,y,bodyColor); + break; + } } } diff --git a/ProjectStormtrooper/src/DrawingStormtrooper.java b/ProjectStormtrooper/src/DrawingStormtrooper.java index fcb9248..3b5b70e 100644 --- a/ProjectStormtrooper/src/DrawingStormtrooper.java +++ b/ProjectStormtrooper/src/DrawingStormtrooper.java @@ -49,13 +49,13 @@ public class DrawingStormtrooper { EntityStormtrooper = new EntityStormtrooper(); EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rockets,bombs ,engines); if(engines==true){ - drawingEngines = new DrawingEngines((int)((Math.random()*3)+1)*2); + drawingEngines = new DrawingEngines(); + drawingEngines.setAmountOfEngines((int)((Math.random()*3)+1)*2);; } _startPosX=null; _startPosY=null; _pictureWidth = null; _pictureHeight = null; - } /// /// Установка границ поля @@ -203,6 +203,7 @@ public class DrawingStormtrooper { g.drawLine(_startPosX+ 50, _startPosY, _startPosX + 60, _startPosY); g.drawLine(_startPosX+ 60, _startPosY, _startPosX + 65, _startPosY + 60); ///Нос бомбардировщика + g.setColor(EntityStormtrooper.getBodyColor()); Point[] Nose = new Point[3]; int[] arrX = {_startPosX + 20, _startPosX,_startPosX+20}; int[] arrY = {_startPosY + 80,_startPosY + 70,_startPosY + 60}; @@ -214,7 +215,6 @@ public class DrawingStormtrooper { g.setColor(EntityStormtrooper.getAdditionalColor()); g.fillRect( _startPosX + 35, _startPosY + 20, 15, 5); g.fillRect( _startPosX + 35, _startPosY + 110, 15, 5); - } //Бомбы бомбардировщика if (EntityStormtrooper.getBombs()) @@ -224,26 +224,7 @@ public class DrawingStormtrooper { g.fillRect(_startPosX + 40, _startPosY + 90, 10, 10); } if(EntityStormtrooper.getEngines() && drawingEngines!=null){ - switch(drawingEngines.getNumberOfEngines()){ - case TWO: - drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 50, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 81, 10, 10,EntityStormtrooper.getBodyColor()); - break; - case FOUR: - drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 10, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 101, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 30, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 121, 10, 10,EntityStormtrooper.getBodyColor()); - break; - case SIX: - drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 10, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 30, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 50, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 65, _startPosY + 81, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 64, _startPosY + 101, 10, 10,EntityStormtrooper.getBodyColor()); - drawingEngines.DrawDecks(g,_startPosX + 62, _startPosY + 121, 10, 10,EntityStormtrooper.getBodyColor()); - break; - } + drawingEngines.SwitchDrawEngines(g, _startPosX, _startPosY, EntityStormtrooper.getBodyColor()); } } } diff --git a/ProjectStormtrooper/src/EntityStormtrooper.java b/ProjectStormtrooper/src/EntityStormtrooper.java index b314e74..4fb6a2f 100644 --- a/ProjectStormtrooper/src/EntityStormtrooper.java +++ b/ProjectStormtrooper/src/EntityStormtrooper.java @@ -12,7 +12,6 @@ public class EntityStormtrooper { public Color getBodyColor() { return BodyColor; } - private Color AdditionalColor; public Color getAdditionalColor() { return AdditionalColor; diff --git a/ProjectStormtrooper/src/FormStormtrooper.java b/ProjectStormtrooper/src/FormStormtrooper.java index e0ca133..0dca398 100644 --- a/ProjectStormtrooper/src/FormStormtrooper.java +++ b/ProjectStormtrooper/src/FormStormtrooper.java @@ -7,16 +7,16 @@ import java.awt.event.ComponentEvent; import java.util.Random; public class FormStormtrooper extends JFrame { - private String title; - private Dimension dimension; + private final String title; + private final Dimension dimension; private int Width; private int Height; - private CanvasStormtrooper canvasStormtrooper = new CanvasStormtrooper(); - private JButton CreateButton = new JButton("Создать");; - private JButton UpButton = new JButton(); - private JButton DownButton = new JButton();; - private JButton LeftButton = new JButton();; - private JButton RightButton = new JButton(); + private final CanvasStormtrooper canvasStormtrooper = new CanvasStormtrooper(); + private final JButton CreateButton = new JButton("Создать"); + private final JButton UpButton = new JButton(); + private final JButton DownButton = new JButton(); + private final JButton LeftButton = new JButton(); + private final JButton RightButton = new JButton(); public FormStormtrooper(String title, Dimension dimension) { this.title = title; this.dimension = dimension; @@ -25,23 +25,21 @@ public class FormStormtrooper extends JFrame { setTitle(title); setMinimumSize(dimension); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Width = getWidth() - 15; - Height = getHeight() - 35; - + Width = getWidth() - 13; + Height = getHeight() - 30; CreateButton.setName("createButton"); - Icon iconUp = new ImageIcon("src\\Resources\\arrowUp.png"); + Icon iconUp = new ImageIcon("Resources\\arrowUp.jpg"); UpButton.setIcon(iconUp); UpButton.setName("UP"); DownButton.setName("DOWN"); - Icon iconDown = new ImageIcon("src\\Resources\\arrowDown.png"); + Icon iconDown = new ImageIcon("Resources\\arrowDown.jpg"); DownButton.setIcon(iconDown); LeftButton.setName("LEFT"); - Icon iconLeft = new ImageIcon("src\\Resources\\arrowLeft.png"); + Icon iconLeft = new ImageIcon("Resources\\arrowLeft.jpg"); LeftButton.setIcon(iconLeft); RightButton.setName("RIGHT"); - Icon iconRight = new ImageIcon("arrowRight.png"); + Icon iconRight = new ImageIcon("Resources\\arrowRight.jpg"); RightButton.setIcon(iconRight); - CreateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -50,12 +48,12 @@ public class FormStormtrooper extends JFrame { int speed = (int)(Math.random() * 300 + 100); float weight = (float) (Math.random() * 3000 + 1000); Color bodyColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); - Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0));; + Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); boolean rockets = new Random().nextBoolean(); - boolean boombs = new Random().nextBoolean();; - boolean engines = new Random().nextBoolean();; + boolean bombs = new Random().nextBoolean(); + boolean engines = new Random().nextBoolean(); canvasStormtrooper._drawingStormtrooper = new DrawingStormtrooper(); - canvasStormtrooper._drawingStormtrooper.Init(speed, weight, bodyColor, additionalColor,rockets, boombs, engines); + canvasStormtrooper._drawingStormtrooper.Init(speed, weight, bodyColor, additionalColor,rockets, bombs, engines); canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); canvasStormtrooper._drawingStormtrooper.SetPosition( StartPositionX, StartPositionY); canvasStormtrooper.repaint(); @@ -66,21 +64,13 @@ public class FormStormtrooper extends JFrame { @Override public void actionPerformed(ActionEvent event) { if (canvasStormtrooper._drawingStormtrooper == null) return; - boolean result = false; - switch ((((JButton)(event.getSource())).getName())) { - case "UP": - result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Up); - break; - case "DOWN": - result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Down); - break; - case "LEFT": - result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Left); - break; - case "RIGHT": - result = canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Right); - break; - } + boolean result = switch ((((JButton) (event.getSource())).getName())) { + case "UP" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Up); + case "DOWN" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Down); + case "LEFT" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Left); + case "RIGHT" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Right); + default -> false; + }; if (result) { canvasStormtrooper.repaint(); } @@ -90,15 +80,14 @@ public class FormStormtrooper extends JFrame { DownButton.addActionListener(actionListener); LeftButton.addActionListener(actionListener); RightButton.addActionListener(actionListener); - setSize(dimension.width,dimension.height); setLayout(null); canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); - CreateButton.setBounds(10, getHeight() - 90, 100, 40); - UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50); - DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50); - RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50); - LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50); + CreateButton.setBounds(10, getHeight() - 90, 130, 40); + UpButton.setBounds(getWidth() - 180, getHeight() - 210, 70, 70); + DownButton.setBounds(getWidth() - 180, getHeight() - 140, 70, 70); + RightButton.setBounds(getWidth() - 110, getHeight() - 140, 70, 70); + LeftButton.setBounds(getWidth() - 250, getHeight() - 140, 70, 70); add(CreateButton); add(UpButton); add(DownButton); @@ -106,19 +95,17 @@ public class FormStormtrooper extends JFrame { add(LeftButton); add(canvasStormtrooper); setVisible(true); - //обработка события изменения размеров окна addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { - Width = getWidth() - 15; - Height = getHeight() - 35; - if (canvasStormtrooper._drawingStormtrooper != null) - canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); + Width = getWidth() - 13; + Height = getHeight() - 30; + if (canvasStormtrooper._drawingStormtrooper != null)canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); - CreateButton.setBounds(10, getHeight() - 90, 100, 40); - UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50); - DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50); - RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50); - LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50); + CreateButton.setBounds(10, getHeight() - 90, 130, 40); + UpButton.setBounds(getWidth() - 180, getHeight() - 210, 70, 70); + DownButton.setBounds(getWidth() - 180, getHeight() - 140, 70, 70); + RightButton.setBounds(getWidth() - 110, getHeight() - 140, 70, 70); + LeftButton.setBounds(getWidth() - 250, getHeight() - 140, 70, 70); } }); } -- 2.25.1 From 51864f5752b14ebf34da3a7194907d24b8df1c2e Mon Sep 17 00:00:00 2001 From: ilyaryabovv Date: Thu, 7 Mar 2024 17:53:06 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/src/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectStormtrooper/src/Main.java b/ProjectStormtrooper/src/Main.java index b4b6838..d12a463 100644 --- a/ProjectStormtrooper/src/Main.java +++ b/ProjectStormtrooper/src/Main.java @@ -2,7 +2,7 @@ import java.awt.*; public class Main { public static void main(String[] args) { - FormStormtrooper form = new FormStormtrooper("Бомбардировщик", new Dimension(800,800)); + FormStormtrooper form = new FormStormtrooper("Бoмбардировщик", new Dimension(800,800)); form.Init(); } } \ No newline at end of file -- 2.25.1 From 78392f46928a3381d8df48e90103b6eb8b95cc86 Mon Sep 17 00:00:00 2001 From: ilyaryabovv Date: Sun, 31 Mar 2024 22:44:49 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=BB=D0=B0=D0=B12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CanvasStormtrooper.java | 8 +- ProjectStormtrooper/src/DirectionType.java | 10 - .../src/DrawingStormtrooper.java | 230 ------------------ .../src/Drawnings/DirectionType.java | 9 + .../Drawnings/DrawingBaseStormtrooper.java | 133 ++++++++++ .../src/Drawnings/DrawingStormtrooper.java | 63 +++++ .../Engines}/DrawingEngines.java | 23 +- .../Drawnings/Engines/DrawingOvalEngines.java | 53 ++++ .../Engines/DrawingTriangleEngines.java | 57 +++++ .../Drawnings/Engines/IDrawingEngines.java | 17 ++ .../Engines}/NumberOfEngines.java | 2 + .../src/Entities/EntityBaseStormtrooper.java | 19 ++ .../src/Entities/EntityStormtrooper.java | 27 ++ .../src/EntityStormtrooper.java | 41 ---- ProjectStormtrooper/src/FormStormtrooper.java | 143 ++++++++--- .../MovementStrategy/AbstractStrategy.java | 60 +++++ .../src/MovementStrategy/IMoveableObject.java | 7 + .../src/MovementStrategy/MoveToBorder.java | 29 +++ .../src/MovementStrategy/MoveToCenter.java | 51 ++++ .../MoveableStormtrooper.java | 46 ++++ .../MovementStrategy/MovementDirection.java | 12 + .../MovementStrategy/ObjectParameters.java | 24 ++ .../src/MovementStrategy/StrategyStatus.java | 7 + 23 files changed, 749 insertions(+), 322 deletions(-) delete mode 100644 ProjectStormtrooper/src/DirectionType.java delete mode 100644 ProjectStormtrooper/src/DrawingStormtrooper.java create mode 100644 ProjectStormtrooper/src/Drawnings/DirectionType.java create mode 100644 ProjectStormtrooper/src/Drawnings/DrawingBaseStormtrooper.java create mode 100644 ProjectStormtrooper/src/Drawnings/DrawingStormtrooper.java rename ProjectStormtrooper/src/{ => Drawnings/Engines}/DrawingEngines.java (70%) create mode 100644 ProjectStormtrooper/src/Drawnings/Engines/DrawingOvalEngines.java create mode 100644 ProjectStormtrooper/src/Drawnings/Engines/DrawingTriangleEngines.java create mode 100644 ProjectStormtrooper/src/Drawnings/Engines/IDrawingEngines.java rename ProjectStormtrooper/src/{ => Drawnings/Engines}/NumberOfEngines.java (96%) create mode 100644 ProjectStormtrooper/src/Entities/EntityBaseStormtrooper.java create mode 100644 ProjectStormtrooper/src/Entities/EntityStormtrooper.java delete mode 100644 ProjectStormtrooper/src/EntityStormtrooper.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/AbstractStrategy.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/IMoveableObject.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/MoveToBorder.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/MoveToCenter.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/MoveableStormtrooper.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/MovementDirection.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/ObjectParameters.java create mode 100644 ProjectStormtrooper/src/MovementStrategy/StrategyStatus.java diff --git a/ProjectStormtrooper/src/CanvasStormtrooper.java b/ProjectStormtrooper/src/CanvasStormtrooper.java index d7254ab..bbd0290 100644 --- a/ProjectStormtrooper/src/CanvasStormtrooper.java +++ b/ProjectStormtrooper/src/CanvasStormtrooper.java @@ -1,16 +1,18 @@ +import Drawnings.DrawingBaseStormtrooper; + import javax.swing.*; import java.awt.*; public class CanvasStormtrooper extends JComponent { - public DrawingStormtrooper _drawingStormtrooper; + public DrawingBaseStormtrooper _drawingBaseStormtrooper; public CanvasStormtrooper(){} public void paintComponent(Graphics g) { - if (_drawingStormtrooper == null) { + if (_drawingBaseStormtrooper == null) { return; } super.paintComponents(g); Graphics2D g2d = (Graphics2D) g; - _drawingStormtrooper.DrawTransport(g2d); + _drawingBaseStormtrooper.DrawTransport(g2d); super.repaint(); } } diff --git a/ProjectStormtrooper/src/DirectionType.java b/ProjectStormtrooper/src/DirectionType.java deleted file mode 100644 index 8f8a5fe..0000000 --- a/ProjectStormtrooper/src/DirectionType.java +++ /dev/null @@ -1,10 +0,0 @@ -public enum DirectionType { - ///Вверх - Up, - ///Вниз - Down, - ///Влево - Left, - ///Вправо - Right -} diff --git a/ProjectStormtrooper/src/DrawingStormtrooper.java b/ProjectStormtrooper/src/DrawingStormtrooper.java deleted file mode 100644 index 3b5b70e..0000000 --- a/ProjectStormtrooper/src/DrawingStormtrooper.java +++ /dev/null @@ -1,230 +0,0 @@ -import java.awt.*; -import java.util.Random; - -public class DrawingStormtrooper { - public EntityStormtrooper EntityStormtrooper; - public DrawingEngines drawingEngines =null; - /// - /// Ширина окна - /// - private Integer _pictureWidth; - - /// - /// Высота окна - /// - private Integer _pictureHeight; - - /// - /// Левая координата прорисовки бомбардировщика - /// - private Integer _startPosX; - - /// - /// Верхняя кооридната прорисовки бомбардировщика - /// - private Integer _startPosY; - - /// - /// Ширина прорисовки бомбардировщика - /// - private final Integer _drawningStormtrooperWidth = 140; - - /// - /// Высота прорисовки бомбардировщика - /// - private final Integer _drawningStormtrooperHeight = 135; - - /// - /// Инициализация свойств - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия двигателей - /// Признак наличия бомб - /// Признак наличия ракет - public void Init(int speed, float weight, Color bodyColor, Color additionalColor,boolean rockets, boolean bombs, boolean engines) - { - EntityStormtrooper = new EntityStormtrooper(); - EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rockets,bombs ,engines); - if(engines==true){ - drawingEngines = new DrawingEngines(); - drawingEngines.setAmountOfEngines((int)((Math.random()*3)+1)*2);; - } - _startPosX=null; - _startPosY=null; - _pictureWidth = null; - _pictureHeight = null; - } - /// - /// Установка границ поля - /// - /// Ширина поля - /// Высота поля - /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах - public boolean SetPictureSize(int width, int height) - { - // TODO проверка, что объект "влезает" в размеры поля - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена - if (width < _drawningStormtrooperWidth || height < _drawningStormtrooperHeight) return false; - _pictureWidth = width; - _pictureHeight = height; - if (_startPosX !=null || _startPosY !=null) - { - if (_startPosX + _drawningStormtrooperWidth > _pictureWidth) - { - _startPosX = -_drawningStormtrooperWidth + _pictureWidth; - } - else if (_startPosX < 0) - { - _startPosX = 0; - } - if (_startPosY + _drawningStormtrooperHeight > _pictureHeight) - { - _startPosY = -_drawningStormtrooperHeight + _pictureHeight; - } - else if (_startPosY < 0) - { - _startPosY = 0; - } - } - return true; - } - /// - /// Установка позиции - /// - /// Координата X - /// Координата Y - public void SetPosition(int x, int y) - { - if (!(_pictureHeight != null && _pictureWidth != null)) return; - // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы - // то надо изменить координаты, чтобы он оставался в этих границах - if (x + _drawningStormtrooperWidth > _pictureWidth) - { - _startPosX = x - (x + _drawningStormtrooperWidth - _pictureWidth); - } - else if (x < 0) - { - _startPosX = 0; - } - else - { - _startPosX = x; - } - if (y + _drawningStormtrooperHeight > _pictureHeight) - { - _startPosY = y - (y + _drawningStormtrooperHeight - _pictureHeight); - } - else if (y < 0) - { - _startPosY = 0; - } - else - { - _startPosY = y; - } - } - - /// - /// Изменение направления перемещения - /// - /// Направление - /// true - перемещене выполнено, false - перемещение невозможно - public boolean MoveTransport(DirectionType direction) - { - if (EntityStormtrooper == null || _startPosX==null || _startPosY==null) - { - return false; - } - switch (direction) - { - //влево - case DirectionType.Left: - if (_startPosX - EntityStormtrooper.Step > 0) - { - _startPosX -= (int)EntityStormtrooper.Step; - } - return true; - //вверх - case DirectionType.Up: - if (_startPosY - EntityStormtrooper.Step > 0) - { - _startPosY -= (int)EntityStormtrooper.Step; - } - return true; - // вправо - case DirectionType.Right: - //TODO прописать логику сдвига в право - if (_startPosX + _drawningStormtrooperWidth + EntityStormtrooper.Step < _pictureWidth) - { - _startPosX += (int)EntityStormtrooper.Step; - }; - return true; - //вниз - case DirectionType.Down: - //TODO прописать логику сдвига в вниз - if (_startPosY + _drawningStormtrooperHeight + EntityStormtrooper.Step < _pictureHeight) - { - _startPosY += (int)EntityStormtrooper.Step; - } - return true; - default: - return false; - } - } - /// - /// Прорисовка объекта - /// - /// - public void DrawTransport(Graphics g) - { - if (EntityStormtrooper == null || _startPosX==null || _startPosY==null) - { - return; - } - g.setColor(Color.black); - //Brush bodyColorBrush = new SolidBrush(EntityStormtrooper.BodyColor); - //Brush additionalBrush = new SolidBrush(EntityStormtrooper.AdditionalColor); - //Тело бомбардировщика - g.drawRect(_startPosX + 20, _startPosY + 60, 120, 20); - //Задние крылья бомбардировщика - g.drawLine(_startPosX+ 140, _startPosY+ 30, _startPosX+ 140, _startPosY+ 110); - g.drawLine(_startPosX+ 120, _startPosY+ 90, _startPosX+ 120, _startPosY+ 80); - g.drawLine(_startPosX+ 140, _startPosY+ 110, _startPosX + 120, _startPosY + 90); - g.drawLine(_startPosX+ 140, _startPosY+ 30, _startPosX+ 120, _startPosY+ 50); - g.drawLine(_startPosX+ 120, _startPosY+ 50, _startPosX+ 120, _startPosY+ 60); - //Крылья бомбардировщика - g.drawLine(_startPosX+ 50, _startPosY, _startPosX + 50, _startPosY + 60); - g.drawLine(_startPosX+ 50, _startPosY + 80, _startPosX + 50, _startPosY + 135); - g.drawLine(_startPosX+ 50, _startPosY + 135, _startPosX + 60, _startPosY + 135); - g.drawLine(_startPosX+ 60, _startPosY + 135, _startPosX + 65, _startPosY + 80); - g.drawLine(_startPosX+ 50, _startPosY, _startPosX + 60, _startPosY); - g.drawLine(_startPosX+ 60, _startPosY, _startPosX + 65, _startPosY + 60); - ///Нос бомбардировщика - g.setColor(EntityStormtrooper.getBodyColor()); - Point[] Nose = new Point[3]; - int[] arrX = {_startPosX + 20, _startPosX,_startPosX+20}; - int[] arrY = {_startPosY + 80,_startPosY + 70,_startPosY + 60}; - Polygon poly = new Polygon(arrX,arrY,3); - g.fillPolygon(poly); - //Ракеты бомбардировщика - if (EntityStormtrooper.getRockets()) - { - g.setColor(EntityStormtrooper.getAdditionalColor()); - g.fillRect( _startPosX + 35, _startPosY + 20, 15, 5); - g.fillRect( _startPosX + 35, _startPosY + 110, 15, 5); - } - //Бомбы бомбардировщика - if (EntityStormtrooper.getBombs()) - { - g.setColor(EntityStormtrooper.getAdditionalColor()); - g.fillRect(_startPosX + 40, _startPosY + 40, 10, 10); - g.fillRect(_startPosX + 40, _startPosY + 90, 10, 10); - } - if(EntityStormtrooper.getEngines() && drawingEngines!=null){ - drawingEngines.SwitchDrawEngines(g, _startPosX, _startPosY, EntityStormtrooper.getBodyColor()); - } - } -} diff --git a/ProjectStormtrooper/src/Drawnings/DirectionType.java b/ProjectStormtrooper/src/Drawnings/DirectionType.java new file mode 100644 index 0000000..293a2f9 --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/DirectionType.java @@ -0,0 +1,9 @@ +package Drawnings; + +public enum DirectionType { + Unknow, + Up, + Down, + Left, + Right +} diff --git a/ProjectStormtrooper/src/Drawnings/DrawingBaseStormtrooper.java b/ProjectStormtrooper/src/Drawnings/DrawingBaseStormtrooper.java new file mode 100644 index 0000000..5460079 --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/DrawingBaseStormtrooper.java @@ -0,0 +1,133 @@ +package Drawnings; +import Entities.*; +import java.awt.*; + +public class DrawingBaseStormtrooper { + public EntityBaseStormtrooper EntityBaseStormtrooper; + protected Integer _pictureWidth; + protected Integer _pictureHeight; + protected Integer _startPosX; + protected Integer _startPosY; + public Integer getPosX(){return _startPosX;} + public Integer getPosY(){return _startPosY;} + private Integer _drawningStormtrooperWidth = 140; + public Integer getWidth(){return _drawningStormtrooperWidth;} + private Integer _drawningStormtrooperHeight = 135; + public Integer getHeight(){return _drawningStormtrooperHeight;} + + protected DrawingBaseStormtrooper(){ + _pictureWidth=null; + _pictureHeight=null; + _startPosX=null; + _startPosY=null; + } + public DrawingBaseStormtrooper(int speed, float weight, Color bodyColor) { + super(); + EntityBaseStormtrooper = new EntityBaseStormtrooper(speed, weight, bodyColor); + } + + public boolean SetPictureSize(int width, int height) { + // TODO проверка, что объект "влезает" в размеры поля + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + if (width < _drawningStormtrooperWidth || height < _drawningStormtrooperHeight) return false; + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX != null || _startPosY != null) { + if (_startPosX + _drawningStormtrooperWidth > _pictureWidth) { + _startPosX = -_drawningStormtrooperWidth + _pictureWidth; + } else if (_startPosX < 0) { + _startPosX = 0; + } + if (_startPosY + _drawningStormtrooperHeight > _pictureHeight) { + _startPosY = -_drawningStormtrooperHeight + _pictureHeight; + } else if (_startPosY < 0) { + _startPosY = 0; + } + } + return true; + } + + public void SetPosition(int x, int y) { + if (!(_pictureHeight != null && _pictureWidth != null)) return; + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + // то надо изменить координаты, чтобы он оставался в этих границах + if (x + _drawningStormtrooperWidth > _pictureWidth) { + _startPosX = x - (x + _drawningStormtrooperWidth - _pictureWidth); + } else if (x < 0) { + _startPosX = 0; + } else { + _startPosX = x; + } + if (y + _drawningStormtrooperHeight > _pictureHeight) { + _startPosY = y - (y + _drawningStormtrooperHeight - _pictureHeight); + } else if (y < 0) { + _startPosY = 0; + } else { + _startPosY = y; + } + } + + public boolean MoveTransport(DirectionType direction) { + if (EntityBaseStormtrooper == null || _startPosX == null || _startPosY == null) { + return false; + } + switch (direction) { + //влево + case DirectionType.Left: + if (_startPosX - EntityBaseStormtrooper.Step > 0) { + _startPosX -= (int) EntityBaseStormtrooper.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY - EntityBaseStormtrooper.Step > 0) { + _startPosY -= (int) EntityBaseStormtrooper.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + if (_startPosX + _drawningStormtrooperWidth + EntityBaseStormtrooper.Step < _pictureWidth) { + _startPosX += (int) EntityBaseStormtrooper.Step; + } + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + if (_startPosY + _drawningStormtrooperHeight + EntityBaseStormtrooper.Step < _pictureHeight) { + _startPosY += (int) EntityBaseStormtrooper.Step; + } + return true; + default: + return false; + } + } + public void DrawTransport(Graphics g) { + if (EntityBaseStormtrooper == null || _startPosX == null || _startPosY == null) { + return; + } + g.setColor(Color.black); + //Тело бомбардировщика + g.drawRect(_startPosX + 20, _startPosY + 60, 120, 20); + //Задние крылья бомбардировщика + g.drawLine(_startPosX + 140, _startPosY + 30, _startPosX + 140, _startPosY + 110); + g.drawLine(_startPosX + 120, _startPosY + 90, _startPosX + 120, _startPosY + 80); + g.drawLine(_startPosX + 140, _startPosY + 110, _startPosX + 120, _startPosY + 90); + g.drawLine(_startPosX + 140, _startPosY + 30, _startPosX + 120, _startPosY + 50); + g.drawLine(_startPosX + 120, _startPosY + 50, _startPosX + 120, _startPosY + 60); + //Крылья бомбардировщика + g.drawLine(_startPosX + 50, _startPosY, _startPosX + 50, _startPosY + 60); + g.drawLine(_startPosX + 50, _startPosY + 80, _startPosX + 50, _startPosY + 135); + g.drawLine(_startPosX + 50, _startPosY + 135, _startPosX + 60, _startPosY + 135); + g.drawLine(_startPosX + 60, _startPosY + 135, _startPosX + 65, _startPosY + 80); + g.drawLine(_startPosX + 50, _startPosY, _startPosX + 60, _startPosY); + g.drawLine(_startPosX + 60, _startPosY, _startPosX + 65, _startPosY + 60); + ///Нос бомбардировщика + g.setColor(EntityBaseStormtrooper.getBodyColor()); + Point[] Nose = new Point[3]; + int[] arrX = {_startPosX + 20, _startPosX, _startPosX + 20}; + int[] arrY = {_startPosY + 80, _startPosY + 70, _startPosY + 60}; + Polygon poly = new Polygon(arrX, arrY, 3); + g.fillPolygon(poly); + } +} diff --git a/ProjectStormtrooper/src/Drawnings/DrawingStormtrooper.java b/ProjectStormtrooper/src/Drawnings/DrawingStormtrooper.java new file mode 100644 index 0000000..4ea2061 --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/DrawingStormtrooper.java @@ -0,0 +1,63 @@ +package Drawnings; +import Drawnings.Engines.DrawingEngines; +import Drawnings.Engines.DrawingOvalEngines; +import Drawnings.Engines.DrawingTriangleEngines; +import Drawnings.Engines.IDrawingEngines; +import Entities.*; +import java.awt.*; + +public class DrawingStormtrooper extends DrawingBaseStormtrooper{ + public IDrawingEngines drawingEngines =null; + public DrawingStormtrooper(int speed, float weight, Color bodyColor, Color additionalColor,boolean rockets, boolean bombs, boolean engines, int typeOfEngines) { + EntityBaseStormtrooper = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, rockets, bombs, engines); + if(engines){ + switch(typeOfEngines){ + case 1: + drawingEngines = new DrawingEngines(); + drawingEngines.setAmountOfEngines((int)((Math.random()*3)+1)*2); + break; + case 2: + drawingEngines = new DrawingTriangleEngines(); + drawingEngines.setAmountOfEngines((int)((Math.random()*3)+1)*2); + break; + case 3: + drawingEngines = new DrawingOvalEngines(); + drawingEngines.setAmountOfEngines((int)((Math.random()*3)+1)*2); + break; + } + + } + _startPosX=null; + _startPosY=null; + _pictureWidth = null; + _pictureHeight = null; + } + + @Override + public void DrawTransport(Graphics g) + { + if (EntityBaseStormtrooper == null ||!(EntityBaseStormtrooper instanceof EntityStormtrooper entityStormtrooper) || _startPosX==null || _startPosY==null) + { + return; + } + super.DrawTransport(g); + //Ракеты бомбардировщика + if (entityStormtrooper.getRockets()) + { + g.setColor(entityStormtrooper.getAdditionalColor()); + g.setColor(entityStormtrooper.getAdditionalColor()); + g.fillRect( _startPosX + 35, _startPosY + 20, 15, 5); + g.fillRect( _startPosX + 35, _startPosY + 110, 15, 5); + } + //Бомбы бомбардировщика + if (entityStormtrooper.getBombs()) + { + g.setColor(entityStormtrooper.getAdditionalColor()); + g.fillRect(_startPosX + 40, _startPosY + 40, 10, 10); + g.fillRect(_startPosX + 40, _startPosY + 90, 10, 10); + } + if(entityStormtrooper.getEngines() && drawingEngines!=null){ + drawingEngines.SwitchDrawEngines(g, _startPosX, _startPosY, EntityBaseStormtrooper.getBodyColor()); + } + } +} diff --git a/ProjectStormtrooper/src/DrawingEngines.java b/ProjectStormtrooper/src/Drawnings/Engines/DrawingEngines.java similarity index 70% rename from ProjectStormtrooper/src/DrawingEngines.java rename to ProjectStormtrooper/src/Drawnings/Engines/DrawingEngines.java index 5e0a692..04d3c91 100644 --- a/ProjectStormtrooper/src/DrawingEngines.java +++ b/ProjectStormtrooper/src/Drawnings/Engines/DrawingEngines.java @@ -1,43 +1,50 @@ +package Drawnings.Engines; import java.awt.*; -public class DrawingEngines { +public class DrawingEngines implements IDrawingEngines { private NumberOfEngines numberOfEngines; + @Override public NumberOfEngines getNumberOfEngines() { return numberOfEngines; } + @Override public void setAmountOfEngines(int amount){ if(NumberOfEngines.contains(amount)) { numberOfEngines = NumberOfEngines.getNumber(amount); } } + @Override public void DrawEngines(Graphics g, int x, int y, Color bodyColor) { g.setColor(bodyColor); g.fillRect(x, y, 10, 10); } - - private void drawTwoEngines(Graphics g, int x, int y, Color bodyColor){ + @Override + public void drawTwoEngines(Graphics g, int x, int y, Color bodyColor){ DrawEngines(g,x + 65, y + 50, bodyColor); DrawEngines(g,x + 65, y + 81,bodyColor); } - private void drawFourEngines(Graphics g, int x, int y, Color bodyColor){ + @Override + public void drawFourEngines(Graphics g, int x, int y, Color bodyColor){ DrawEngines(g,x + 62, y + 10,bodyColor); DrawEngines(g,x + 64, y + 101,bodyColor); DrawEngines(g,x + 64, y + 30,bodyColor); DrawEngines(g,x + 62, y + 121,bodyColor); } - private void drawSixEngines(Graphics g, int x, int y, Color bodyColor){ + @Override + public void drawSixEngines(Graphics g, int x, int y, Color bodyColor){ drawFourEngines(g,x,y,bodyColor); drawTwoEngines(g,x,y,bodyColor); } + @Override public void SwitchDrawEngines(Graphics g, int x, int y, Color bodyColor){ switch(getNumberOfEngines()){ - case TWO: + case NumberOfEngines.TWO: drawTwoEngines(g,x,y,bodyColor); break; - case FOUR: + case NumberOfEngines.FOUR: drawFourEngines(g,x,y,bodyColor); break; - case SIX: + case NumberOfEngines.SIX: drawSixEngines(g,x,y,bodyColor); break; } diff --git a/ProjectStormtrooper/src/Drawnings/Engines/DrawingOvalEngines.java b/ProjectStormtrooper/src/Drawnings/Engines/DrawingOvalEngines.java new file mode 100644 index 0000000..012fc2a --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/Engines/DrawingOvalEngines.java @@ -0,0 +1,53 @@ +package Drawnings.Engines; + +import java.awt.*; + +public class DrawingOvalEngines implements IDrawingEngines { + private NumberOfEngines numberOfEngines; + @Override + public NumberOfEngines getNumberOfEngines() { + return numberOfEngines; + } + @Override + public void setAmountOfEngines(int amount){ + if(NumberOfEngines.contains(amount)) { + numberOfEngines = NumberOfEngines.getNumber(amount); + } + } + @Override + public void DrawEngines(Graphics g, int x, int y, Color bodyColor) { + g.setColor(bodyColor); + g.fillOval(x, y, 10, 10); + } + @Override + public void drawTwoEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 65, y + 50, bodyColor); + DrawEngines(g,x + 65, y + 81,bodyColor); + } + public @Override + void drawFourEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 62, y + 10,bodyColor); + DrawEngines(g,x + 64, y + 101,bodyColor); + DrawEngines(g,x + 64, y + 30,bodyColor); + DrawEngines(g,x + 62, y + 121,bodyColor); + } + @Override + public void drawSixEngines(Graphics g, int x, int y, Color bodyColor){ + drawFourEngines(g,x,y,bodyColor); + drawTwoEngines(g,x,y,bodyColor); + } + @Override + public void SwitchDrawEngines(Graphics g, int x, int y, Color bodyColor){ + switch(getNumberOfEngines()){ + case NumberOfEngines.TWO: + drawTwoEngines(g,x,y,bodyColor); + break; + case NumberOfEngines.FOUR: + drawFourEngines(g,x,y,bodyColor); + break; + case NumberOfEngines.SIX: + drawSixEngines(g,x,y,bodyColor); + break; + } + } +} diff --git a/ProjectStormtrooper/src/Drawnings/Engines/DrawingTriangleEngines.java b/ProjectStormtrooper/src/Drawnings/Engines/DrawingTriangleEngines.java new file mode 100644 index 0000000..510be8e --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/Engines/DrawingTriangleEngines.java @@ -0,0 +1,57 @@ +package Drawnings.Engines; + +import java.awt.*; + +public class DrawingTriangleEngines implements IDrawingEngines { + private NumberOfEngines numberOfEngines; + @Override + public NumberOfEngines getNumberOfEngines() { + return numberOfEngines; + } + @Override + public void setAmountOfEngines(int amount){ + if(NumberOfEngines.contains(amount)) { + numberOfEngines = NumberOfEngines.getNumber(amount); + } + } + @Override + public void DrawEngines(Graphics g, int x, int y, Color bodyColor) { + g.setColor(bodyColor); + Point[] Nose = new Point[3]; + int[] arrX = {x,x,x+10}; + int[] arrY = {y,y+12,y+6}; + Polygon poly = new Polygon(arrX, arrY, 3); + g.fillPolygon(poly); + } + @Override + public void drawTwoEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 65, y + 50, bodyColor); + DrawEngines(g,x + 65, y + 81,bodyColor); + } + public @Override + void drawFourEngines(Graphics g, int x, int y, Color bodyColor){ + DrawEngines(g,x + 62, y + 10,bodyColor); + DrawEngines(g,x + 64, y + 101,bodyColor); + DrawEngines(g,x + 64, y + 30,bodyColor); + DrawEngines(g,x + 62, y + 121,bodyColor); + } + @Override + public void drawSixEngines(Graphics g, int x, int y, Color bodyColor){ + drawFourEngines(g,x,y,bodyColor); + drawTwoEngines(g,x,y,bodyColor); + } + public void SwitchDrawEngines(Graphics g, int x, int y, Color bodyColor){ + switch(getNumberOfEngines()){ + case NumberOfEngines.TWO: + drawTwoEngines(g,x,y,bodyColor); + break; + case NumberOfEngines.FOUR: + drawFourEngines(g,x,y,bodyColor); + break; + case NumberOfEngines.SIX: + drawSixEngines(g,x,y,bodyColor); + break; + } + } +} + diff --git a/ProjectStormtrooper/src/Drawnings/Engines/IDrawingEngines.java b/ProjectStormtrooper/src/Drawnings/Engines/IDrawingEngines.java new file mode 100644 index 0000000..366fe13 --- /dev/null +++ b/ProjectStormtrooper/src/Drawnings/Engines/IDrawingEngines.java @@ -0,0 +1,17 @@ +package Drawnings.Engines; + +import java.awt.*; + +public interface IDrawingEngines { + void setAmountOfEngines(int amount); + + NumberOfEngines getNumberOfEngines(); + + void DrawEngines(Graphics g, int x, int y, Color bodyColor); + + void drawTwoEngines(Graphics g, int x, int y, Color bodyColor); + void drawFourEngines(Graphics g, int x, int y, Color bodyColor); + void drawSixEngines(Graphics g, int x, int y, Color bodyColor); + void SwitchDrawEngines(Graphics g, int startPosX, int startPosY, Color bodyColor); + +} diff --git a/ProjectStormtrooper/src/NumberOfEngines.java b/ProjectStormtrooper/src/Drawnings/Engines/NumberOfEngines.java similarity index 96% rename from ProjectStormtrooper/src/NumberOfEngines.java rename to ProjectStormtrooper/src/Drawnings/Engines/NumberOfEngines.java index 1d0775e..5b9208d 100644 --- a/ProjectStormtrooper/src/NumberOfEngines.java +++ b/ProjectStormtrooper/src/Drawnings/Engines/NumberOfEngines.java @@ -1,3 +1,5 @@ +package Drawnings.Engines; + public enum NumberOfEngines { TWO(2), FOUR(4), diff --git a/ProjectStormtrooper/src/Entities/EntityBaseStormtrooper.java b/ProjectStormtrooper/src/Entities/EntityBaseStormtrooper.java new file mode 100644 index 0000000..3616188 --- /dev/null +++ b/ProjectStormtrooper/src/Entities/EntityBaseStormtrooper.java @@ -0,0 +1,19 @@ +package Entities; + +import java.awt.*; + +public class EntityBaseStormtrooper +{ + private int Speed; + private float Weight; + private Color BodyColor; + public Color getBodyColor() {return BodyColor;} + public double Step; + public EntityBaseStormtrooper(int speed, float weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + Step=speed*100/weight; + } +} diff --git a/ProjectStormtrooper/src/Entities/EntityStormtrooper.java b/ProjectStormtrooper/src/Entities/EntityStormtrooper.java new file mode 100644 index 0000000..1ee9923 --- /dev/null +++ b/ProjectStormtrooper/src/Entities/EntityStormtrooper.java @@ -0,0 +1,27 @@ +package Entities; + +import java.awt.*; +public class EntityStormtrooper extends EntityBaseStormtrooper{ + private Color AdditionalColor; + public Color getAdditionalColor() { + return AdditionalColor; + } + private boolean Rockets; + public boolean getRockets() { + return Rockets; + } + private boolean Bombs; + public boolean getBombs() { + return Bombs; + } + private boolean Engines; + public boolean getEngines() {return Engines;} + public EntityStormtrooper(int speed, float weight, Color bodyColor, Color additionalColor, boolean rockets, boolean bombs, boolean engines) + { + super(speed,weight,bodyColor); + AdditionalColor = additionalColor; + Rockets = rockets; + Bombs = bombs; + Engines = engines; + } +} diff --git a/ProjectStormtrooper/src/EntityStormtrooper.java b/ProjectStormtrooper/src/EntityStormtrooper.java deleted file mode 100644 index 4fb6a2f..0000000 --- a/ProjectStormtrooper/src/EntityStormtrooper.java +++ /dev/null @@ -1,41 +0,0 @@ -import java.awt.*; -public class EntityStormtrooper { - private int Speed; - public int getSpeed() { - return Speed; - } - private float Weight; - public float getWeight() { - return Weight; - } - private Color BodyColor; - public Color getBodyColor() { - return BodyColor; - } - private Color AdditionalColor; - public Color getAdditionalColor() { - return AdditionalColor; - } - private boolean Rockets; - public boolean getRockets() { - return Rockets; - } - private boolean Bombs; - public boolean getBombs() { - return Bombs; - } - private boolean Engines; - public boolean getEngines() {return Engines;} - public float Step; - public void Init(int speed, float weight, Color bodyColor, Color additionalColor, boolean rockets, boolean bombs, boolean engines) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - AdditionalColor = additionalColor; - Rockets = rockets; - Bombs = bombs; - Engines = engines; - Step = Speed * 100 / Weight; - } -} diff --git a/ProjectStormtrooper/src/FormStormtrooper.java b/ProjectStormtrooper/src/FormStormtrooper.java index 0dca398..9eacf7d 100644 --- a/ProjectStormtrooper/src/FormStormtrooper.java +++ b/ProjectStormtrooper/src/FormStormtrooper.java @@ -6,13 +6,22 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.util.Random; +import Drawnings.DirectionType; +import Drawnings.DrawingBaseStormtrooper; +import Drawnings.DrawingStormtrooper; +import MovementStrategy.*; + public class FormStormtrooper extends JFrame { + private AbstractStrategy _strategy; private final String title; private final Dimension dimension; private int Width; private int Height; private final CanvasStormtrooper canvasStormtrooper = new CanvasStormtrooper(); - private final JButton CreateButton = new JButton("Создать"); + private JComboBox ComboBoxStrategy = new JComboBox(new String []{"К центру", "К краю"}); + private JButton ButtonStrategy = new JButton("Шаг"); + private final JButton CreateBaseStormtrooper = new JButton("Создать базовый бомбардировщик"); + private final JButton CreateStormtrooper = new JButton("Создать бомбардировщик"); private final JButton UpButton = new JButton(); private final JButton DownButton = new JButton(); private final JButton LeftButton = new JButton(); @@ -21,13 +30,45 @@ public class FormStormtrooper extends JFrame { this.title = title; this.dimension = dimension; } + private void CreateObject(String typeOfClass){ + int StartPositionX = (int)(Math.random() * 90 + 10); + int StartPositionY = (int)(Math.random() * 90 + 10); + int speed = (int)(Math.random() * 300 + 100); + float weight = (float) (Math.random() * 3000 + 1000); + Color bodyColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); + switch (typeOfClass){ + case "Drawnings.DrawingBaseStormtrooper": + canvasStormtrooper._drawingBaseStormtrooper = new DrawingBaseStormtrooper(speed, weight, bodyColor); + canvasStormtrooper._drawingBaseStormtrooper.SetPictureSize(Width, Height); + canvasStormtrooper._drawingBaseStormtrooper.SetPosition( StartPositionX, StartPositionY); + canvasStormtrooper.repaint(); + break; + case "Drawnings.DrawingStormtrooper": + Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); + boolean rockets = new Random().nextBoolean(); + boolean bombs = new Random().nextBoolean(); + boolean engines = new Random().nextBoolean(); + int typeOfEngine = ((int)((Math.random()*3)+1)); + canvasStormtrooper._drawingBaseStormtrooper = new DrawingStormtrooper(speed, weight, bodyColor, additionalColor,rockets, bombs, engines, typeOfEngine); + canvasStormtrooper._drawingBaseStormtrooper.SetPictureSize(Width, Height); + canvasStormtrooper._drawingBaseStormtrooper.SetPosition( StartPositionX, StartPositionY); + canvasStormtrooper.repaint(); + break; + default: + return; + } + _strategy=null; + ComboBoxStrategy.setEnabled(true); + } public void Init() { setTitle(title); setMinimumSize(dimension); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Width = getWidth() - 13; - Height = getHeight() - 30; - CreateButton.setName("createButton"); + Width = getWidth()-10; + Height = getHeight() - 34; + _strategy=null; + CreateStormtrooper.setName("createStormtrooperButton"); + CreateBaseStormtrooper.setName("createBaseStormtrooperButton"); Icon iconUp = new ImageIcon("Resources\\arrowUp.jpg"); UpButton.setIcon(iconUp); UpButton.setName("UP"); @@ -40,35 +81,68 @@ public class FormStormtrooper extends JFrame { RightButton.setName("RIGHT"); Icon iconRight = new ImageIcon("Resources\\arrowRight.jpg"); RightButton.setIcon(iconRight); - CreateButton.addActionListener(new ActionListener() { + ButtonStrategy.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { - int StartPositionX = (int)(Math.random() * 90 + 10); - int StartPositionY = (int)(Math.random() * 90 + 10); - int speed = (int)(Math.random() * 300 + 100); - float weight = (float) (Math.random() * 3000 + 1000); - Color bodyColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); - Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0)); - boolean rockets = new Random().nextBoolean(); - boolean bombs = new Random().nextBoolean(); - boolean engines = new Random().nextBoolean(); - canvasStormtrooper._drawingStormtrooper = new DrawingStormtrooper(); - canvasStormtrooper._drawingStormtrooper.Init(speed, weight, bodyColor, additionalColor,rockets, bombs, engines); - canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); - canvasStormtrooper._drawingStormtrooper.SetPosition( StartPositionX, StartPositionY); - canvasStormtrooper.repaint(); + if (canvasStormtrooper._drawingBaseStormtrooper == null) return; + if (ComboBoxStrategy.isEnabled()) + { + int index = ComboBoxStrategy.getSelectedIndex(); + switch(index) + { + case 1: + _strategy = new MoveToBorder(); + break; + case 0: + _strategy = new MoveToCenter(); + break; + default: + _strategy = null; + break; + }; + if (_strategy == null) + { + return; + } + _strategy.SetData(new MoveableStormtrooper(canvasStormtrooper._drawingBaseStormtrooper), Width, Height); + } + if (_strategy == null) + { + return; + } + ComboBoxStrategy.setEnabled(false); + _strategy.MakeStep(); + if (_strategy.GetStatus() == StrategyStatus.Finish) + { + ComboBoxStrategy.setEnabled(true); + _strategy = null; + } } }); + CreateBaseStormtrooper.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + CreateObject("Drawnings.DrawingBaseStormtrooper"); + } + }); + CreateStormtrooper.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + CreateObject("Drawnings.DrawingStormtrooper"); + } + }); + ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - if (canvasStormtrooper._drawingStormtrooper == null) return; + if (canvasStormtrooper._drawingBaseStormtrooper == null) return; boolean result = switch ((((JButton) (event.getSource())).getName())) { - case "UP" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Up); - case "DOWN" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Down); - case "LEFT" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Left); - case "RIGHT" -> canvasStormtrooper._drawingStormtrooper.MoveTransport(DirectionType.Right); + case "UP" -> canvasStormtrooper._drawingBaseStormtrooper.MoveTransport(DirectionType.Up); + case "DOWN" -> canvasStormtrooper._drawingBaseStormtrooper.MoveTransport(DirectionType.Down); + case "LEFT" -> canvasStormtrooper._drawingBaseStormtrooper.MoveTransport(DirectionType.Left); + case "RIGHT" -> canvasStormtrooper._drawingBaseStormtrooper.MoveTransport(DirectionType.Right); default -> false; }; if (result) { @@ -83,12 +157,18 @@ public class FormStormtrooper extends JFrame { setSize(dimension.width,dimension.height); setLayout(null); canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); - CreateButton.setBounds(10, getHeight() - 90, 130, 40); + CreateBaseStormtrooper.setBounds(10, getHeight() - 90, 130, 40); + CreateStormtrooper.setBounds(160,getHeight()-90,130,40); UpButton.setBounds(getWidth() - 180, getHeight() - 210, 70, 70); DownButton.setBounds(getWidth() - 180, getHeight() - 140, 70, 70); RightButton.setBounds(getWidth() - 110, getHeight() - 140, 70, 70); LeftButton.setBounds(getWidth() - 250, getHeight() - 140, 70, 70); - add(CreateButton); + ComboBoxStrategy.setBounds(getWidth() - 170, 10, 140, 35); + ButtonStrategy.setBounds(getWidth() - 130, 55, 100, 25); + add(CreateBaseStormtrooper); + add(CreateStormtrooper); + add(ComboBoxStrategy); + add(ButtonStrategy); add(UpButton); add(DownButton); add(RightButton); @@ -97,15 +177,18 @@ public class FormStormtrooper extends JFrame { setVisible(true); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { - Width = getWidth() - 13; - Height = getHeight() - 30; - if (canvasStormtrooper._drawingStormtrooper != null)canvasStormtrooper._drawingStormtrooper.SetPictureSize(Width, Height); + Width = getWidth() -10; + Height = getHeight() - 34; + if (canvasStormtrooper._drawingBaseStormtrooper != null)canvasStormtrooper._drawingBaseStormtrooper.SetPictureSize(Width, Height); canvasStormtrooper.setBounds(0,0, getWidth(), getHeight()); - CreateButton.setBounds(10, getHeight() - 90, 130, 40); + CreateBaseStormtrooper.setBounds(10, getHeight() - 90, 130, 40); + CreateStormtrooper.setBounds(160,getHeight()-90,130,40); UpButton.setBounds(getWidth() - 180, getHeight() - 210, 70, 70); DownButton.setBounds(getWidth() - 180, getHeight() - 140, 70, 70); RightButton.setBounds(getWidth() - 110, getHeight() - 140, 70, 70); LeftButton.setBounds(getWidth() - 250, getHeight() - 140, 70, 70); + ComboBoxStrategy.setBounds(getWidth() - 170, 10, 140, 35); + ButtonStrategy.setBounds(getWidth() - 130, 55, 100, 25); } }); } diff --git a/ProjectStormtrooper/src/MovementStrategy/AbstractStrategy.java b/ProjectStormtrooper/src/MovementStrategy/AbstractStrategy.java new file mode 100644 index 0000000..c13ae17 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/AbstractStrategy.java @@ -0,0 +1,60 @@ +package MovementStrategy; +public abstract class AbstractStrategy +{ + private IMoveableObject _moveableObject; + private StrategyStatus _state = StrategyStatus.NotInit; + public int FieldWidth; + public int FieldHeight; + public StrategyStatus GetStatus (){ return _state; } + public void SetData(IMoveableObject moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = StrategyStatus.NotInit; + return; + } + _state = StrategyStatus.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + public void MakeStep() + { + if (_state != StrategyStatus.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = StrategyStatus.Finish; + return; + } + MoveToTarget(); + } + + protected boolean MoveLeft() {return MoveTo(MovementDirection.Left);} + protected boolean MoveRight() {return MoveTo(MovementDirection.Right);} + protected boolean MoveUp(){return MoveTo(MovementDirection.Up);} + protected boolean MoveDown(){return MoveTo(MovementDirection.Down);} + + protected ObjectParameters GetObjectParameters (){return _moveableObject.GetObjectPosition();} + protected int GetStep(){ + if (_state != StrategyStatus.InProgress) + { + return -1; + } + return _moveableObject.getStep(); + } + protected abstract void MoveToTarget(); + protected abstract boolean IsTargetDestinaion(); + private boolean MoveTo(MovementDirection movementDirection) { + if (_state != StrategyStatus.InProgress) { + return false; + } + if (_moveableObject.TryMoveObject(movementDirection)) { + return _moveableObject.TryMoveObject(movementDirection); + } + return false; + } +} \ No newline at end of file diff --git a/ProjectStormtrooper/src/MovementStrategy/IMoveableObject.java b/ProjectStormtrooper/src/MovementStrategy/IMoveableObject.java new file mode 100644 index 0000000..ae0259a --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/IMoveableObject.java @@ -0,0 +1,7 @@ +package MovementStrategy; +public interface IMoveableObject +{ + ObjectParameters GetObjectPosition (); + int getStep(); + boolean TryMoveObject(MovementDirection direction); +} \ No newline at end of file diff --git a/ProjectStormtrooper/src/MovementStrategy/MoveToBorder.java b/ProjectStormtrooper/src/MovementStrategy/MoveToBorder.java new file mode 100644 index 0000000..bc84419 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/MoveToBorder.java @@ -0,0 +1,29 @@ +package MovementStrategy; +public class MoveToBorder extends AbstractStrategy +{ + @Override + protected boolean IsTargetDestinaion() + { + ObjectParameters objParams = GetObjectParameters(); + if (objParams == null) + { + return false; + } + return objParams.LeftBorder - GetStep() <= 0 && + objParams.RightBorder + GetStep() >= FieldWidth && + objParams.TopBorder - GetStep() <= 0 + && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight; + } + @Override + protected void MoveToTarget() + { + ObjectParameters objParams = GetObjectParameters(); + if (objParams == null) { + return; + } + int x = objParams.RightBorder; + if (x + GetStep() < FieldWidth)MoveRight(); + int y = objParams.DownBorder; + if (y + GetStep() < FieldHeight) MoveDown(); + } +} diff --git a/ProjectStormtrooper/src/MovementStrategy/MoveToCenter.java b/ProjectStormtrooper/src/MovementStrategy/MoveToCenter.java new file mode 100644 index 0000000..a3e72bb --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/MoveToCenter.java @@ -0,0 +1,51 @@ +package MovementStrategy; +public class MoveToCenter extends AbstractStrategy +{ + @Override + protected boolean IsTargetDestinaion() + { + ObjectParameters objParams = GetObjectParameters(); + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && + objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && + objParams.ObjectMiddleVertical + GetStep() >= FieldHeight /2; + } + + @Override + protected void MoveToTarget() { + + ObjectParameters objParams = GetObjectParameters(); + if (objParams == null) + { + return; + } + int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} \ No newline at end of file diff --git a/ProjectStormtrooper/src/MovementStrategy/MoveableStormtrooper.java b/ProjectStormtrooper/src/MovementStrategy/MoveableStormtrooper.java new file mode 100644 index 0000000..63210a4 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/MoveableStormtrooper.java @@ -0,0 +1,46 @@ +package MovementStrategy; +import Drawnings.*; +import Entities.EntityBaseStormtrooper; +public class MoveableStormtrooper implements IMoveableObject +{ + private DrawingBaseStormtrooper _stormtrooper ; + + public MoveableStormtrooper(DrawingBaseStormtrooper stormtrooper) + { + _stormtrooper = stormtrooper; + } + @Override + public ObjectParameters GetObjectPosition() { + if (_stormtrooper == null || _stormtrooper.EntityBaseStormtrooper == null || _stormtrooper.getPosX()==null || _stormtrooper.getPosY()==null) { + return null; + } + return new ObjectParameters(_stormtrooper.getPosX(), _stormtrooper.getPosY(), _stormtrooper.getWidth(), _stormtrooper.getHeight()); + } + @Override + public int getStep(){ return (int)(_stormtrooper.EntityBaseStormtrooper.Step);} + @Override + public boolean TryMoveObject(MovementDirection direction) + { + if (_stormtrooper == null || _stormtrooper.EntityBaseStormtrooper == null) + { + return false; + } + return _stormtrooper.MoveTransport(GetDirectionType(direction)); + } + private static DirectionType GetDirectionType(MovementDirection direction) { + switch (direction) { + case Left: + return DirectionType.Left; + case Right: + return DirectionType.Right; + case Up: + return DirectionType.Up; + case Down: + return DirectionType.Down; + default: + return DirectionType.Unknow; + } + } +} + + diff --git a/ProjectStormtrooper/src/MovementStrategy/MovementDirection.java b/ProjectStormtrooper/src/MovementStrategy/MovementDirection.java new file mode 100644 index 0000000..2aa1079 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/MovementDirection.java @@ -0,0 +1,12 @@ +package MovementStrategy; +public enum MovementDirection { + ///Вверх + Up, + ///Вниз + Down, + ///Влево + Left, + ///Вправо + Right + +} diff --git a/ProjectStormtrooper/src/MovementStrategy/ObjectParameters.java b/ProjectStormtrooper/src/MovementStrategy/ObjectParameters.java new file mode 100644 index 0000000..e23f255 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/ObjectParameters.java @@ -0,0 +1,24 @@ +package MovementStrategy; +public class ObjectParameters +{ + private int _x; + private int _y; + public int _width; + private int _height; + public int TopBorder =_y; + public int LeftBorder = _x; + public int RightBorder = _x + _width; + public int DownBorder = _y + _height; + public int ObjectMiddleHorizontal; + public int ObjectMiddleVertical; + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + ObjectMiddleHorizontal = _x + _width/ 2; + ObjectMiddleVertical = _y + _height/ 2; + + } +} \ No newline at end of file diff --git a/ProjectStormtrooper/src/MovementStrategy/StrategyStatus.java b/ProjectStormtrooper/src/MovementStrategy/StrategyStatus.java new file mode 100644 index 0000000..27691d3 --- /dev/null +++ b/ProjectStormtrooper/src/MovementStrategy/StrategyStatus.java @@ -0,0 +1,7 @@ +package MovementStrategy; +public enum StrategyStatus +{ + NotInit, + InProgress, + Finish +} -- 2.25.1 From 375d70cb468e7c7bded1db6495ae478a7b860d55 Mon Sep 17 00:00:00 2001 From: Ilya Ryabov Date: Sat, 27 Apr 2024 16:48:44 +0400 Subject: [PATCH 5/5] revert 51864f5752b14ebf34da3a7194907d24b8df1c2e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert Правки --- ProjectStormtrooper/src/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectStormtrooper/src/Main.java b/ProjectStormtrooper/src/Main.java index d12a463..b4b6838 100644 --- a/ProjectStormtrooper/src/Main.java +++ b/ProjectStormtrooper/src/Main.java @@ -2,7 +2,7 @@ import java.awt.*; public class Main { public static void main(String[] args) { - FormStormtrooper form = new FormStormtrooper("Бoмбардировщик", new Dimension(800,800)); + FormStormtrooper form = new FormStormtrooper("Бомбардировщик", new Dimension(800,800)); form.Init(); } } \ No newline at end of file -- 2.25.1