package ProjectElectricLocomotive; import java.awt.*; public class DrawingElectricLocomotive extends DrawingLocomotive { public DrawingElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, boolean horns, boolean seifBatteries, int width, int height) { super(speed, weight, bodyColor, width, height, 150, 50); if (EntityLocomotive != null) { EntityLocomotive = new EntityElectricLocomotive(speed, width, bodyColor, additionalColor, horns, seifBatteries); } } public DrawingElectricLocomotive(EntityElectricLocomotive entityElectricLocomotive, IDrawingWheels iDrawingWheels, int width, int height) { super(entityElectricLocomotive,iDrawingWheels, width, height, 150, 50); } @Override public void DrawTransport(Graphics g) { if (EntityLocomotive instanceof EntityElectricLocomotive electricLocomotive) ///////// WARNING INSTANCEOF { Color addColor = electricLocomotive.AdditionalColor; if (electricLocomotive.Horns) { //horns g.setColor(addColor); g.fillRect(_startPosX + 30, _startPosY + 15, 20, 5); g.drawLine(_startPosX + 40, _startPosY + 15, _startPosX + 50, _startPosY + 10); g.drawLine(_startPosX + 50, _startPosY + 10, _startPosX + 45, _startPosY); g.drawLine(_startPosX + 45, _startPosY + 15, _startPosX + 50, _startPosY + 10); g.drawLine(_startPosX + 50, _startPosY + 10, _startPosX + 40, _startPosY); } if (electricLocomotive.SeifBatteries) { g.setColor(addColor); g.fillRect(_startPosX + 80, _startPosY + 30, 5, 10); } super.DrawTransport(g); } } }