From c5a1a44785902cc2e92a3b2c7371e2351db05367 Mon Sep 17 00:00:00 2001 From: olshab Date: Sun, 10 Dec 2023 17:07:30 +0400 Subject: [PATCH] fix strategies --- src/AirBomber/BomberForm.java | 6 +++--- src/AirBomber/MovementStrategy/MoveToCenterStrategy.java | 4 ++-- src/AirBomber/MovementStrategy/MoveToDownRightStrategy.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AirBomber/BomberForm.java b/src/AirBomber/BomberForm.java index 0e0b7b6..cab4ef6 100644 --- a/src/AirBomber/BomberForm.java +++ b/src/AirBomber/BomberForm.java @@ -85,7 +85,7 @@ public class BomberForm extends JFrame break; case 1: - _strategy = new MoveToCenterStrategy(); + _strategy = new MoveToDownRightStrategy(); break; default: @@ -165,7 +165,7 @@ public class BomberForm extends JFrame // ButtonCreateBomberBase // ButtonCreateBomberBase.setName("ButtonCreateBomberBase"); - ButtonCreateBomberBase.setBounds(177, 407, 159, 42); + ButtonCreateBomberBase.setBounds(12, 383, 260, 30); ButtonCreateBomberBase.setText("Создать бомбардировщик"); ButtonCreateBomberBase.setBackground(new Color(225, 225, 225)); ButtonCreateBomberBase.setFont(new Font("Segoe UI", Font.PLAIN, 11)); @@ -221,7 +221,7 @@ public class BomberForm extends JFrame // ButtonCreateBomber // ButtonCreateBomber.setName("ButtonCreateBomber"); - ButtonCreateBomber.setBounds(12, 407, 159, 42); + ButtonCreateBomber.setBounds(12, 419, 260, 30); ButtonCreateBomber.setText("Создать продвинутый бомбардировщик"); ButtonCreateBomber.setBackground(new Color(225, 225, 225)); ButtonCreateBomber.setFont(new Font("Segoe UI", Font.PLAIN, 11)); diff --git a/src/AirBomber/MovementStrategy/MoveToCenterStrategy.java b/src/AirBomber/MovementStrategy/MoveToCenterStrategy.java index 481dc6c..0026907 100644 --- a/src/AirBomber/MovementStrategy/MoveToCenterStrategy.java +++ b/src/AirBomber/MovementStrategy/MoveToCenterStrategy.java @@ -25,7 +25,7 @@ public class MoveToCenterStrategy extends AbstractStrategy return; float diffX = ObjParams.ObjectMiddleHorizontal() - FieldWidth / 2; - if (Math.abs(diffX) > GetStep()) + if (Math.abs(diffX) >= GetStep()) { if (diffX > 0) MoveLeft(); @@ -34,7 +34,7 @@ public class MoveToCenterStrategy extends AbstractStrategy } float diffY = ObjParams.ObjectMiddleVertical() - FieldHeight / 2; - if (Math.abs(diffY) > GetStep()) + if (Math.abs(diffY) >= GetStep()) { if (diffY > 0) MoveUp(); diff --git a/src/AirBomber/MovementStrategy/MoveToDownRightStrategy.java b/src/AirBomber/MovementStrategy/MoveToDownRightStrategy.java index 8889077..d9171ac 100644 --- a/src/AirBomber/MovementStrategy/MoveToDownRightStrategy.java +++ b/src/AirBomber/MovementStrategy/MoveToDownRightStrategy.java @@ -24,7 +24,7 @@ public class MoveToDownRightStrategy extends AbstractStrategy return; float diffX = ObjParams.RightBorder() - FieldWidth; - if (Math.abs(diffX) > GetStep()) + if (Math.abs(diffX) >= GetStep()) { if (diffX > 0) MoveLeft(); @@ -33,7 +33,7 @@ public class MoveToDownRightStrategy extends AbstractStrategy } float diffY = ObjParams.BottomBorder() - FieldHeight; - if (Math.abs(diffY) > GetStep()) + if (Math.abs(diffY) >= GetStep()) { if (diffY > 0) MoveUp();