PIbd-22_Bondarenko_M.S._War.../DrawningMotorShip.java
Макс Бондаренко 82055e73fe интерфейс
2022-11-29 00:27:51 +04:00

46 lines
1.7 KiB
Java

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