diff --git a/src/AbstractStrategy.java b/src/AbstractStrategy.java index 1845d4a..9ed2f1f 100644 --- a/src/AbstractStrategy.java +++ b/src/AbstractStrategy.java @@ -6,6 +6,7 @@ public abstract class AbstractStrategy { private int fieldHeight; protected int getFieldHeight(){return fieldHeight;} public Status getStatus() {return state;} + public void setData(IMoveableObject moveableObject, int width, int height){ if (moveableObject == null) { diff --git a/src/DrawingBus.java b/src/DrawingBus.java index fc783f1..67f9467 100644 --- a/src/DrawingBus.java +++ b/src/DrawingBus.java @@ -1,4 +1,5 @@ import java.awt.*; + public class DrawingBus { protected EntityBus entityBus; public EntityBus getEntityBus() { diff --git a/src/DrawingDoors.java b/src/DrawingDoors.java index 53df0a9..b49182c 100644 --- a/src/DrawingDoors.java +++ b/src/DrawingDoors.java @@ -1,4 +1,5 @@ import java.awt.*; + public class DrawingDoors implements IDrawDoors{ private DoorsNumber number; @Override diff --git a/src/DrawingDoorsRoundedUp.java b/src/DrawingDoorsRoundedUp.java index 8c781ec..8f12b1f 100644 --- a/src/DrawingDoorsRoundedUp.java +++ b/src/DrawingDoorsRoundedUp.java @@ -1,4 +1,5 @@ import java.awt.*; + public class DrawingDoorsRoundedUp implements IDrawDoors{ private DoorsNumber number; @Override diff --git a/src/DrawingDoorsRoundedUpAndDown.java b/src/DrawingDoorsRoundedUpAndDown.java index ad962a6..c912f83 100644 --- a/src/DrawingDoorsRoundedUpAndDown.java +++ b/src/DrawingDoorsRoundedUpAndDown.java @@ -1,4 +1,5 @@ import java.awt.*; + public class DrawingDoorsRoundedUpAndDown implements IDrawDoors{ private DoorsNumber number; @Override diff --git a/src/DrawingObjectBus.java b/src/DrawingObjectBus.java index 4ecc71b..9d42096 100644 --- a/src/DrawingObjectBus.java +++ b/src/DrawingObjectBus.java @@ -3,6 +3,7 @@ public class DrawingObjectBus implements IMoveableObject{ public DrawingObjectBus(DrawingBus drawingBus){ this.drawingBus = drawingBus; } + @Override public ObjectParameters getObjectPosition(){ if(drawingBus == null || drawingBus.getEntityBus() == null) diff --git a/src/DrawingTrolleybus.java b/src/DrawingTrolleybus.java index 4441ae4..7d8d9fa 100644 --- a/src/DrawingTrolleybus.java +++ b/src/DrawingTrolleybus.java @@ -1,4 +1,5 @@ import java.awt.*; + public class DrawingTrolleybus extends DrawingBus{ public DrawingTrolleybus(int speed, double weight, Color bodyColor, Color additionalColor, boolean roga, boolean battery, int width, int height, int doorsNumber, int doorsType) diff --git a/src/EntityBus.java b/src/EntityBus.java index 30392e6..7a8ce5f 100644 --- a/src/EntityBus.java +++ b/src/EntityBus.java @@ -1,5 +1,6 @@ import java.awt.*; import java.util.function.Supplier; + public class EntityBus { private int speed; public int getSpeed() { diff --git a/src/EntityTrolleybus.java b/src/EntityTrolleybus.java index 84f8463..e01e66a 100644 --- a/src/EntityTrolleybus.java +++ b/src/EntityTrolleybus.java @@ -1,4 +1,5 @@ import java.awt.*; + public class EntityTrolleybus extends EntityBus{ private Color additionalColor; public Color getAdditionalColor(){return additionalColor;} diff --git a/src/FrameTrolleybus.java b/src/FrameTrolleybus.java index 6bb4fc4..b754968 100644 --- a/src/FrameTrolleybus.java +++ b/src/FrameTrolleybus.java @@ -5,6 +5,7 @@ import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; import java.util.Random; + public class FrameTrolleybus extends JFrame { private DrawingBus drawingBus; private AbstractStrategy abstractStrategy; diff --git a/src/IDrawDoors.java b/src/IDrawDoors.java index 2cc00b1..17b7798 100644 --- a/src/IDrawDoors.java +++ b/src/IDrawDoors.java @@ -1,4 +1,5 @@ import java.awt.*; + public interface IDrawDoors { void setNumber(int x); void drawDoors(Graphics2D graphics2D, int _startX, int _startY); diff --git a/src/IMoveableObject.java b/src/IMoveableObject.java index 329d7ad..3fed604 100644 --- a/src/IMoveableObject.java +++ b/src/IMoveableObject.java @@ -1,5 +1,6 @@ public interface IMoveableObject { ObjectParameters getObjectPosition(); + int getStep(); boolean checkCanMove(DirectionType direction); void moveObject(DirectionType direction); diff --git a/src/MoveToBorder.java b/src/MoveToBorder.java index 29a93bd..505a85e 100644 --- a/src/MoveToBorder.java +++ b/src/MoveToBorder.java @@ -8,6 +8,7 @@ public class MoveToBorder extends AbstractStrategy{ return objParams.getRightBorder() + getStep() >= getFieldWidth() && objParams.getDownBorder() + getStep() >= getFieldHeight(); } + @Override protected void moveToTarget() { var objParams = getObjectParameters(); diff --git a/src/MoveToCenter.java b/src/MoveToCenter.java index 0bcde1b..7c48527 100644 --- a/src/MoveToCenter.java +++ b/src/MoveToCenter.java @@ -9,6 +9,7 @@ public class MoveToCenter extends AbstractStrategy{ objParams.getObjectMiddleVertical() <= getFieldHeight() / 2 && objParams.getObjectMiddleVertical() + getStep() >= getFieldHeight() / 2; } + @Override protected void moveToTarget() { ObjectParameters objParams = getObjectParameters(); diff --git a/src/ObjectParameters.java b/src/ObjectParameters.java index 2026666..56847c2 100644 --- a/src/ObjectParameters.java +++ b/src/ObjectParameters.java @@ -9,6 +9,7 @@ public class ObjectParameters { public int getDownBorder() {return POS_Y + HEIGHT;} public int getObjectMiddleHorizontal() {return POS_X + this.WIDTH / 2;} public int getObjectMiddleVertical() {return POS_Y + this.HEIGHT / 2;} + public ObjectParameters(int x, int y, int width, int height) { POS_X = x; diff --git a/src/Status.java b/src/Status.java index c773b40..d16c65b 100644 --- a/src/Status.java +++ b/src/Status.java @@ -2,4 +2,5 @@ public enum Status { NOT_INIT, IN_PROGRESS, FINISH + }