From 82055e73fed01ff299363cbb532f8baa7a3c7ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 29 Nov 2022 00:27:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawningMotorShip.java | 45 ++++++++++++++++++++++++++++++++++++++++++ EntityMotorShip.java | 21 ++++++++++++++++++++ IDrawningObject.java | 9 +++++++++ 3 files changed, 75 insertions(+) create mode 100644 DrawningMotorShip.java create mode 100644 EntityMotorShip.java create mode 100644 IDrawningObject.java diff --git a/DrawningMotorShip.java b/DrawningMotorShip.java new file mode 100644 index 0000000..f77ed25 --- /dev/null +++ b/DrawningMotorShip.java @@ -0,0 +1,45 @@ +import java.awt.*; + +public class DrawningMotorShip extends DrawingShip { + public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, boolean tubes, boolean cistern) + { + super(speed, weight, bodyColor, 150, 75); + warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern); + } + + @Override + public void DrawTransport(Graphics g) + { + if (!(warmlyShip instanceof EntityMotorShip motorShip)) + { + return; + } + + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.BLACK); + g2d.setColor(motorShip.GetDopColor()); + if (motorShip.GetTubes()) + { + g2d.setColor(motorShip.GetDopColor()); + g2d.fillRect((int)_startPosX + _warmlyShipWidth / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g2d.setColor(Color.BLACK); + g2d.drawRect((int)_startPosX + _warmlyShipWidth / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g2d.setColor(motorShip.GetDopColor()); + g2d.fillRect((int)_startPosX + _warmlyShipWidth * 3 / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + g2d.setColor(Color.BLACK); + g2d.drawRect((int)_startPosX + _warmlyShipWidth * 3 / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2); + } + + _startPosY += 25; + super.DrawTransport(g); + _startPosY -= 25; + + if (motorShip.GetCistern()) + { + g2d.setColor(motorShip.GetDopColor()); + g2d.fillOval((int)_startPosX, (int)_startPosY + 25, 25, 20); + g2d.setColor(Color.BLACK); + g2d.drawOval((int)_startPosX, (int)_startPosY + 25, 25, 20); + } + } +} diff --git a/EntityMotorShip.java b/EntityMotorShip.java new file mode 100644 index 0000000..b8e16c2 --- /dev/null +++ b/EntityMotorShip.java @@ -0,0 +1,21 @@ +import java.awt.*; + +public class EntityMotorShip extends EntityWarmlyShip { + private Color DopColor; + private boolean Tubes; + private boolean Cistern; + + public EntityMotorShip(int speed, float weight, Color bodyColor, Color dopColor, boolean tubes, boolean cistern) + { + super(speed, weight, bodyColor); + DopColor = dopColor; + Tubes = tubes; + Cistern = cistern; + } + + public Color GetDopColor(){return DopColor;} + + public boolean GetTubes(){return Tubes;} + + public boolean GetCistern(){return Cistern;} +} diff --git a/IDrawningObject.java b/IDrawningObject.java new file mode 100644 index 0000000..af06c5b --- /dev/null +++ b/IDrawningObject.java @@ -0,0 +1,9 @@ +import java.awt.*; + +public interface IDrawningObject { + float getStep(); + void SetObject(int x, int y, int width, int height); + void MoveObject(Direction direction); + void DrawningObject(Graphics g); + float[] GetCurrentPosition(); +}