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(); +}