From 673ba65efe5375c5de6ce965969cfb32f28be709 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 8 Oct 2022 18:08:44 +0400 Subject: [PATCH] Added and Fixed DrawningObjectLocomotive --- DrawningObjectLocomotive.java | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 DrawningObjectLocomotive.java diff --git a/DrawningObjectLocomotive.java b/DrawningObjectLocomotive.java new file mode 100644 index 0000000..38617df --- /dev/null +++ b/DrawningObjectLocomotive.java @@ -0,0 +1,39 @@ +import java.awt.*; + +public class DrawningObjectLocomotive implements IDrawningObject { + private DrawningLocomotive _locomotive = null; + + public DrawningObjectLocomotive(DrawningLocomotive locomotive) + { + _locomotive = locomotive; + } + public float getStep() { + if (_locomotive.Locomotive != null) { + return _locomotive.Locomotive.Step(); + } + return 0; + } + + public void DrawningObject(Graphics g) + { + if (_locomotive != null) _locomotive.DrawTransport((Graphics2D) g); + } + + public float[] GetCurrentPosition() + { + if (_locomotive != null) { + return _locomotive.GetCurrentPosition(); + } + return null; + } + + public void MoveObject(Direction direction) + { + if (_locomotive != null) _locomotive.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + if (_locomotive != null) _locomotive.SetPosition(x, y, width, height); + } +}