38 lines
1.6 KiB
Java
38 lines
1.6 KiB
Java
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);
|
|
}
|
|
}
|
|
@Override
|
|
public void DrawTransport(Graphics g)
|
|
{
|
|
if (EntityLocomotive instanceof EntityElectricLocomotive electricLocomotive) ///////// WARNING INSTANCEOF
|
|
{
|
|
Color colorBlack = Color.BLACK;
|
|
|
|
if (electricLocomotive.Horns) {
|
|
//horns
|
|
g.setColor(colorBlack);
|
|
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(colorBlack);
|
|
g.fillRect(_startPosX + 80, _startPosY + 30, 5, 10);
|
|
}
|
|
super.DrawTransport(g);
|
|
}
|
|
}
|
|
}
|