PIbd-12_Karamushko_M.K._Air.../DrawingTruncatedEngines.java

52 lines
1.4 KiB
Java
Raw Permalink Normal View History

2022-11-10 16:44:45 +04:00
import java.awt.*;
public class DrawingTruncatedEngines implements IDrawingEngines {
private EnginesCount enginesCount;
private Color color;
public DrawingTruncatedEngines(int count, Color bodyColor) {
setCount(count);
color = bodyColor;
}
@Override
public void setCount(int count) {
if(count <= 2) enginesCount = EnginesCount.Two;
else if(count >= 6) enginesCount = EnginesCount.Six;
else enginesCount = EnginesCount.Four;
}
2022-11-29 17:50:40 +04:00
@Override
public void setColor(Color color) {
this.color = color;
}
2022-12-02 11:17:40 +04:00
@Override
public int getCount() {
if(enginesCount == EnginesCount.Two) return 2;
if(enginesCount == EnginesCount.Four) return 4;
return 6;
}
@Override
public Color getColor() {
return color;
}
2022-11-10 16:44:45 +04:00
public void draw(Graphics2D g, int startPosX, int startPosY) {
g.setPaint(color);
g.fillArc(startPosX + 90, startPosY + 10, 30, 15, 90, 180);
g.fillArc(startPosX + 90, startPosY + 141, 30, 15, 90, 180);
if(enginesCount == EnginesCount.Two) return;
g.fillArc(startPosX + 90, startPosY + 30, 30, 15, 90, 180);
g.fillArc(startPosX + 90, startPosY + 121, 30, 15, 90, 180);
if(enginesCount == EnginesCount.Four) return;
g.fillArc(startPosX + 90, startPosY + 50, 30, 15, 90, 180);
g.fillArc(startPosX + 90, startPosY + 101, 30, 15, 90, 180);
}
}