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

40 lines
1.1 KiB
Java
Raw Normal View History

2022-10-28 21:18:49 +04:00
import java.awt.*;
2022-11-10 16:44:45 +04:00
public class DrawingEngines implements IDrawingEngines {
2022-10-28 21:18:49 +04:00
private EnginesCount enginesCount;
private Color color;
2022-11-10 16:44:45 +04:00
public DrawingEngines(int count, Color bodyColor) {
2022-11-02 09:51:14 +04:00
setCount(count);
color = bodyColor;
}
2022-11-10 16:44:45 +04:00
@Override
2022-11-02 09:51:14 +04:00
public void setCount(int count) {
2022-10-28 21:18:49 +04:00
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-10-28 21:18:49 +04:00
public void draw(Graphics2D g, int startPosX, int startPosY) {
g.setPaint(color);
2022-11-10 16:44:45 +04:00
g.fillOval(startPosX + 80, startPosY + 10, 30, 15);
g.fillOval(startPosX + 80, startPosY + 141, 30, 15);
2022-10-28 21:18:49 +04:00
if(enginesCount == EnginesCount.Two) return;
2022-11-10 16:44:45 +04:00
g.fillOval(startPosX + 80, startPosY + 30, 30, 15);
g.fillOval(startPosX + 80, startPosY + 121, 30, 15);
2022-10-28 21:18:49 +04:00
if(enginesCount == EnginesCount.Four) return;
2022-11-10 16:44:45 +04:00
g.fillOval(startPosX + 80, startPosY + 50, 30, 15);
g.fillOval(startPosX + 80, startPosY + 101, 30, 15);
2022-10-28 21:18:49 +04:00
}
}