Добавление интерфейса и класса отрисовки объектов

This commit is contained in:
prodigygirl 2022-10-22 22:50:54 +04:00
parent 107ff418db
commit cdb5b9f8fe
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import java.awt.*;
import java.util.HashMap;
public class DrawingObjectArmoredCar implements IDrawingObject{
private DrawingArmoredCar armoredCar = null;
public DrawingObjectArmoredCar(DrawingArmoredCar armoredCar) {
this.armoredCar = armoredCar;
}
@Override
public float getStep() {
if (armoredCar != null)
return armoredCar.armoredCar.step;
return 0;
}
@Override
public void SetObject(int x, int y, int width, int height) {
if (armoredCar != null)
armoredCar.SetPosition(x, y, width, height);
}
@Override
public void MoveObject(Direction direction) {
if (armoredCar != null)
armoredCar.MoveTransport(direction);
}
@Override
public void DrawingObject(Graphics2D g) {
if (armoredCar != null)
armoredCar.DrawTransport(g);
}
@Override
public HashMap<String, Float> GetCurrentPosition() {
return armoredCar.GetCurrentPosition();
}
}

View File

@ -0,0 +1,14 @@
import java.awt.*;
import java.util.HashMap;
public interface IDrawingObject {
float getStep();
void SetObject(int x, int y, int width, int height);
void MoveObject(Direction direction);
void DrawingObject(Graphics2D g);
HashMap<String, Float> GetCurrentPosition();
}