This commit is contained in:
Yunusov_Niyaz 2023-11-04 02:32:04 +04:00
parent 43d4951e5d
commit dc8923d850
16 changed files with 16 additions and 0 deletions

View File

@ -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)
{

View File

@ -1,4 +1,5 @@
import java.awt.*;
public class DrawingBus {
protected EntityBus entityBus;
public EntityBus getEntityBus() {

View File

@ -1,4 +1,5 @@
import java.awt.*;
public class DrawingDoors implements IDrawDoors{
private DoorsNumber number;
@Override

View File

@ -1,4 +1,5 @@
import java.awt.*;
public class DrawingDoorsRoundedUp implements IDrawDoors{
private DoorsNumber number;
@Override

View File

@ -1,4 +1,5 @@
import java.awt.*;
public class DrawingDoorsRoundedUpAndDown implements IDrawDoors{
private DoorsNumber number;
@Override

View File

@ -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)

View File

@ -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)

View File

@ -1,5 +1,6 @@
import java.awt.*;
import java.util.function.Supplier;
public class EntityBus {
private int speed;
public int getSpeed() {

View File

@ -1,4 +1,5 @@
import java.awt.*;
public class EntityTrolleybus extends EntityBus{
private Color additionalColor;
public Color getAdditionalColor(){return additionalColor;}

View File

@ -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;

View File

@ -1,4 +1,5 @@
import java.awt.*;
public interface IDrawDoors {
void setNumber(int x);
void drawDoors(Graphics2D graphics2D, int _startX, int _startY);

View File

@ -1,5 +1,6 @@
public interface IMoveableObject {
ObjectParameters getObjectPosition();
int getStep();
boolean checkCanMove(DirectionType direction);
void moveObject(DirectionType direction);

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -2,4 +2,5 @@ public enum Status {
NOT_INIT,
IN_PROGRESS,
FINISH
}