PIbd-23_Mochalov_D.V._Locom.../ExtraWheelsDraw.java

52 lines
1.5 KiB
Java
Raw Permalink Normal View History

2022-09-25 13:45:19 +04:00
import java.awt.*;
public class ExtraWheelsDraw implements IDrawningExtra{
2022-09-27 16:26:05 +04:00
private WheelsCount wheelsCount = WheelsCount.Two;
public void setExtraNum(int num) {
2022-09-27 16:26:05 +04:00
switch (num) {
2022-09-25 13:45:19 +04:00
case 0: {
wheelsCount = WheelsCount.Three;
break;
}
2022-09-27 16:26:05 +04:00
case 1: {
2022-09-25 13:45:19 +04:00
wheelsCount = WheelsCount.Four;
break;
}
2022-09-27 16:26:05 +04:00
default:
break;
2022-09-25 13:45:19 +04:00
}
}
2022-09-27 16:26:05 +04:00
private Color color;
2022-09-25 13:45:19 +04:00
public ExtraWheelsDraw(int num, Color color) {
setExtraNum(num);
2022-09-25 13:45:19 +04:00
this.color = color;
}
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
2022-10-08 23:13:09 +04:00
g.setColor(Color.BLACK);
g.drawOval(startPosX, startPosY + 30, 20, 20);
g.drawOval(startPosX + 90, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
g.setColor(color);
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX, startPosY + 30, 20, 20);
g.fillOval(startPosX + 90, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
switch (wheelsCount) {
2022-09-27 16:26:05 +04:00
case Four: {
2022-10-08 23:13:09 +04:00
g.setColor(Color.BLACK);
g.drawOval(startPosX + 70, startPosY + 30, 20, 20);
g.setColor(color);
g.fillOval(startPosX + 70, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
}
case Three: {
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX + 20, startPosY + 30, 20, 20);
g.setColor(Color.BLACK);
g.drawOval(startPosX + 20, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
break;
}
2022-09-27 16:26:05 +04:00
default:
break;
2022-09-25 13:45:19 +04:00
}
}
2022-09-27 16:26:05 +04:00
2022-09-25 13:45:19 +04:00
}