Add interface

This commit is contained in:
ArtemEmelyanov 2022-11-29 00:25:21 +04:00
parent 41e6816ee5
commit 56c85de909
3 changed files with 60 additions and 0 deletions

38
DrawningObjectPlane.java Normal file
View File

@ -0,0 +1,38 @@
import java.awt.*;
public class DrawningObjectPlane implements IDrawningObject {
private DrawningPlane _plane = null;
public DrawningObjectPlane(DrawningPlane plane)
{
_plane = plane;
}
public float Step() {
if(_plane != null && _plane.Plane != null)
return _plane.Plane.Step;
return 0;
}
@Override
public void SetObject(int x, int y, int width, int height) {
_plane.SetPosition(x,y,width,height);
}
@Override
public void MoveObject(Direction direction) {
_plane.MoveTransport(direction);
}
@Override
public void DrawingObject(Graphics g) {
_plane.DrawTransport(g);
}
@Override
public float[] GetCurrentPosition() {
if(_plane!=null)
return _plane.GetCurrentPosition();
return null;
}
}

View File

@ -143,4 +143,13 @@ public class DrawningPlane extends JPanel {
_startPosY = _pictureHeight - _PlaneHeight;
}
}
public float[] GetCurrentPosition() {
float[] dim = new float[4];
dim[0] = _startPosX;
dim[1] =_startPosY;
dim[2] = _startPosX + _PlaneWidth;
dim[3] = _startPosY + _PlaneHeight;
return dim;
}
}

13
IDrawningObject.java Normal file
View File

@ -0,0 +1,13 @@
import java.awt.*;
public interface IDrawningObject {
public float Step = 0;
void SetObject(int x, int y, int width, int height);
void MoveObject(Direction direction);
void DrawingObject(Graphics g);
float[] GetCurrentPosition();
}